DataStep Studio Install
Documentation

How-to guide

Short recipes for everyday SAS work.

On this page
How-to guide
  1. Connect for the first time
  2. Switch between SAS OnDemand and the company server
  3. Run only the step I am in
  4. Run everything up to here
  5. Stop a program that runs too long
  6. Find out why the log is not clean
  7. Flag a NOTE our team does not accept
  8. Look at the data set I just made
  9. Keep only two treatment arms in the data viewer
  10. Write a PROC SORT in five seconds
  11. Type a WHERE value without looking it up
  12. Open the macro my program calls
  13. Call my macro with all its parameters
  14. Clean up a long macro call
  15. Tidy up a messy program
  16. Comment out a few lines
  17. Bring my keyboard macros from SAS
  18. Keep a piece of code I write again and again
  19. Run my whole study, program after program
  20. Debug a macro loop (Professional)
  21. Look inside a macro while it runs (Professional)
  22. Find the step that breaks a long run (Professional)
  23. Go through a program step by step (Professional)
  24. Watch a DATA step work (Professional)
  25. Change LINESIZE (or any system option)
  26. Give a command my own key
  27. Keep my layout
  28. Keep my programs on my computer and run them on SAS OnDemand
  29. Work directly on files on SAS OnDemand
  30. Copy programs to the server, or fetch logs and outputs (Professional)
  31. See which edition I have

Connect for the first time

  1. Run DataStep Studio: Check Setup. It finds Java and Python. If SASPy is missing, click Install SASPy.
  2. Run DataStep Studio: Add New Connection Profile → SAS OnDemand for Academics.
  3. Choose your home region (it is in the web address of SAS Studio, e.g. euw1 = Europe 1) and enter your user ID.
  4. Click Connect Now and enter your password. It is asked once and kept in your computer's keychain.
  5. Open a .sas file and press F4.

Switch between SAS OnDemand and the company server

  1. Add a second profile: Add New Connection Profile → SAS 9.4 server (IOM) → host, port, user.
  2. Run DataStep Studio: Switch Connection Profile and pick the one you want.

The status bar shows the active profile. The next run connects with it.

Run only the step I am in

  1. Put the cursor in the step.
  2. Click Run Step in the title bar (the ▷ menu).
  3. Pick what to run: a single SQL statement, the whole PROC or DATA step, the macro call or the %MACRO definition.

Run everything up to here

Put the cursor on a line and press Ctrl+Alt+Up. Everything from the top down to that line runs; a step that contains the line runs completely.

Stop a program that runs too long

Click Stop SAS in the status bar (it appears while SAS runs). The running code stops, like Ctrl+Break in SAS. Your WORK data sets and macro variables stay.

Find out why the log is not clean

  1. Open the Suspicious Log tab, next to the SAS Log.
  2. It lists only the ERRORs, WARNINGs and NOTEs that matter (uninitialized variables, missing values generated, repeats of BY values …), from every run.
  3. Click a line: the cursor jumps to the statement that caused it.

Flag a NOTE our team does not accept

  1. Open the settings and search for datastepStudio.log.suspiciousNotes.
  2. Click Add Item and enter a pattern, for example Table WORK\.\w+ created, with 0 rows.

A message you know is harmless goes into datastepStudio.log.suspiciousIgnore instead.

Look at the data set I just made

Press F12. Or double-click the data set in Libraries, or press Ctrl+Alt+D with the cursor on its name in your program.

Keep only two treatment arms in the data viewer

  1. Click a cell with one of the two arms, for example Drug 10 mg, in the treatment column.
  2. Press Ctrl+Alt+I: that value is ticked already. Tick the second, Drug 20 mg, with Space.
  3. Press Enter. The WHERE box now holds trt01p IN ('Drug 10 mg', 'Drug 20 mg').

Ctrl+Alt+E keeps only the value of the cell; Ctrl+Alt+R shows all rows again.

Write a PROC SORT in five seconds

Type sort and press Tab: PROC SORT DATA=have OUT=want; BY usubjid; RUN;. Press Tab to jump from have to want to usubjid and type over them. (With Professional, proc so + Enter also suggests your own data sets and keys.)

Type a WHERE value without looking it up

Type WHERE paramcd = ' and the values of PARAMCD in your data appear, the most frequent first. (Professional)

Open the macro my program calls

Right-click the call (for example %derive_vars_dtm(...)) → Open Macro Definition / Included Program. Or Cmd+click / Ctrl+click it. The file that defines the macro opens at its %MACRO line. On a %INCLUDE "file" statement the same opens the included program.

Call my macro with all its parameters

Type % and the first letters of your macro (%deri for %derive_vars_dtm) and press Enter. The call is written with every parameter and its defaults. Press Tab to go from value to value. (Professional)

Clean up a long macro call

Put the cursor in the call and press Ctrl+Shift+O: the parameters at their default disappear. Press it again: the call goes on one line. Ctrl+Shift+E shows every parameter again. (Professional)

Tidy up a messy program

Right-click in the program → Format SAS Program. Keywords go upper case, names lower case, two spaces per level, one statement per line. To format only a part, highlight it and press Ctrl+Shift+F. Changed your mind? Cmd+Z (Ctrl+Z) takes it back.

Comment out a few lines

Highlight the lines and press Ctrl+K (Mac: Cmd+K). Each line gets /* */. Press it again to remove them.

Bring my keyboard macros from SAS

  1. In the SAS Enhanced Editor: Tools → Keyboard Macros → Macros → Export. You get a .kmf file.
  2. In VS Code: DataStep Studio: Import Keyboard Macros from SAS (.kmf) and pick the file.
  3. Type a name in a program and press Tab.

Keep a piece of code I write again and again

  1. Highlight the code.
  2. Right-click → Save Selection as Keyboard Macro…
  3. Give it a name, for example adslmerge. From now on adslmerge + Tab writes it.

Run my whole study, program after program

  1. Name the programs in the order they should run: 01_adsl.sas, 02_adae.sas, …
  2. In the Explorer, right-click their folder → Run in Batch.
  3. Keep working. Each program runs in a fresh SAS session and gets its .log file next to it.

Debug a macro loop (Professional)

  1. Open the program with the macro and click the blue Debug Macro button in the title bar.
  2. In the call pane above the macro, fill in the parameters.
  3. Click in the margin of a line inside the loop to set a breakpoint. Right-click it → Edit Breakpoint… → &i. = 5.
  4. Click Start Debug. F5 runs to the breakpoint; the Variables tab shows the macro variables.

Look inside a macro while it runs (Professional)

  1. Write %pry(when=&i. = 3) on its own line inside the macro, where you want to look.
  2. Run the program as always (F4). The run stops there, and the SAS Pry terminal opens.
  3. Type ls for the macro variables, vt work.mydata and freq sex for a data set as it is now.
  4. Type n to go on one line (Enter repeats it), c to go on to the end.
  5. To try code there: type edit, write the code in the editor that opens (autocomplete works), press F4.

Find the step that breaks a long run (Professional)

  1. Write %pry(rescue=Y) on its own line after the part that fails, for example at the end of the macro.
  2. Run as always (F4). The run stops right after the first step with an ERROR, before the next one.
  3. The SAS Pry terminal shows the ERROR. Type ls and vt to see the macro variables and the data of that moment.
  4. Fix the program, then type !!! to end the run, or c to let it go on.

Add warning=Y to stop at the first WARNING too.

Go through a program step by step (Professional)

  1. Write %pry on its own line before the step where you want to start, between two steps.
  2. Run as always (F4). Everything before it runs, then the program waits.
  3. Type next to run the next step and wait again; press Enter to do it once more. Look at the data with vt in between.
  4. Type c to run the rest.

Watch a DATA step work (Professional)

  1. Put the cursor in the DATA step and click Debug DATA Step in the title bar (or press F5).
  2. Press F10 to run one statement at a time. The Variables view shows every variable.
  3. To stop at one observation, give a breakpoint a condition, e.g. usubjid = "TEST12".

Change LINESIZE (or any system option)

  1. Open the Options tab and click 🔍.
  2. Type linesize, press Enter, type the new value, press Enter.

The row now shows (changed, was 132); ↺ puts the old value back.

Give a command my own key

Press F9 to open Keys. Click + next to the command and press the keys. ↺ puts the default back.

Keep my layout

Arrange the SAS tabs as you like, then type WSAVE ALL in the SAS command box (Ctrl+Alt+C). The same tabs open the next time SAS connects.

Keep my programs on my computer and run them on SAS OnDemand

Nothing to do: open the folder in VS Code and press F4. Before each run DataStep Studio copies the changed files of your project to the server and runs the program there, so %INCLUDE and LIBNAME with relative paths work. Use Git as usual on your computer.

Work directly on files on SAS OnDemand

Run DataStep Studio: Open SAS Server Folder. A window opens on your SAS OnDemand home: open, edit and save server programs as if they were local. To copy a folder there, drag it from Finder or Windows Explorer onto a folder in that window.

Copy programs to the server, or fetch logs and outputs (Professional)

  1. Run DataStep Studio: Open File Manager: your computer is on the left, the SAS server on the right.
  2. Go to the folders you need on both sides: arrow keys, Enter to open, Backspace to go up, Tab to change sides. Ctrl+L (Cmd+L) lets you type a folder; ~ is your home folder.
  3. Mark the files with Space (or Ctrl+A / Cmd+A for all).
  4. Press F5 to copy them to the other side, or F6 to move them. Enter confirms.

Dragging files to the other side works too. A name that exists there is asked about first.

See which edition I have

Run DataStep Studio: License and Edition. During Early Access it says Community Early Access: all Professional features are free.