DataStep Studio Install
New %pry: the complete tutorial, in 7 minutes

Write, run and debug SAS. In VS Code.

One key runs your code. The log points to the line. Your data opens with a double-click. And you can watch a DATA step or a macro work, line by line.

For SAS OnDemand for Academics and SAS 9.4 servers · Free during Community Early Access · Nothing collected

The film, 70 seconds, recorded in VS Code on SAS OnDemand: run and read the log, look at your data, write faster, and when a number looks wrong, the DATA step debugger, the macro debugger and %pry.

Run

One key runs it. The log points to the line.

Changed one line? Run just that step, not the whole 2,000-line program. The log comes back in colour, and every ERROR is marked right at its line in your program.

A SAS program in VS Code with the coloured SAS log below and the error marked in Problems
  • F4 runs itThe selection or the program. F3 and F8 work as in SAS.
  • Run To Line, Run StepAnd Resolve Code, one click away.
  • Stop SASRunning too long? Stop it. Your WORK data stays.

Suspicious Log

A 3,000-line log. Only the lines that matter.

The Suspicious Log keeps the ERRORs, the WARNINGs and the NOTEs a QC review looks for. A click jumps to the statement.

The Suspicious Log tab with one error, one warning and three notes, each with its program line

Data viewer

Your data, one double-click away.

Check a data set without a single PROC PRINT. Filter, sort, look at frequencies. Tick the values you want, and the WHERE clause is written for you.

The complete tutorial, 7 minutes, recorded on SAS OnDemand with the CDISC pilot ADAE: open, move, frequencies, every filter, the value picker, columns, search, and severe adverse events from the first click to the count. Jump to a chapter:

  1. why the viewer
  2. open a data set
  3. move around
  4. one column at a glance
  5. filter with a WHERE
  6. a filter per column
  7. the value picker
  8. sort, columns, labels, raw
  9. search, Open…, the keys
  10. severe adverse events
  11. the keys on one screen
  • f on a columnIts frequencies and statistics. Click a value to keep it.
  • Ctrl+Alt+I on a columnTick the values; the WHERE is written as you tick.
  • Ctrl+Alt+E on a cellWHERE … = that value.
  • Libraries, Variables, OptionsAnd Created Files, beside your code.

Debuggers

No more PUT _ALL_ and guessing.

Set a breakpoint. Step through the code statement by statement. Watch every variable change. For DATA steps, and for macros.

The DATA step debuggerThe macro debugger%pry

Which one when?

DATA step debugger

One row at a time.

  • A value is wrong for some observations of a DATA step.
  • You want to see the PDV: what SAS keeps and what it sets back, with RETAIN, FIRST./LAST. or a MERGE with IN=.
  • A condition such as usubjid = "01-701-1023" stops at the one subject you care about.
The DATA step debugger ›

Macro debugger

One macro, line by line.

  • You write or test a macro: Debug Macro starts it with the parameters you choose.
  • Step into the macros it calls and watch every macro variable change. Nothing changes in your code.
  • After the run, every line shows how often it ran, so the branches your test never reached stand out.
The macro debugger ›

%pry

Your real program, stopped where you want.

  • A long program gives a wrong number: write %pry where you suspect it and run as always.
  • Look at the data as it is at that moment, even the temporary data sets a macro deletes at its end.
  • %pry(rescue=Y) stops right after the first step that ends with an ERROR. In macros, in DATA steps and between steps.
%pry ›
“Why is this variable wrong for these rows?”
DATA step debugger
“How does this macro work, and does every branch work?”
Macro debugger
“Why is this number wrong in my program?”
%pry where you suspect it
“Where does my program fail?”
%pry(rescue=Y)

They work together: at a %pry stop, step goes into the macro called there, line by line.

DATA step debugger

Watch the PDV change, statement by statement.

A conditional breakpoint such as usubjid = "TEST12" stops right at the observation you care about.

The complete tutorial, 6 minutes, recorded on SAS OnDemand: a counter that never starts again, found and fixed. Jump to a chapter:

  1. why the debugger
  2. start it
  3. one statement at a time
  4. stop at one subject
  5. try the fix first
  6. watch a variable
  7. fix it in the code
  8. MERGE and IN=
  9. a step that calls a macro
  10. recap

Step with F10. See every value.

The PDV is in the Variables view. Hover a variable for its value, or change a value. A DATA step that calls a macro is expanded first, so you step through the statements it generates.

In the manual

adsl.sas · DATA steppaused on step
1▶DATA work.adsl;
2▶ SET sashelp.class;
3▶ bmi = ROUND(weight / height**2 * 703, 0.1);
4▶ IF age < 13 THEN agegr1 = '<13';
5▶ ELSE IF age <= 14 THEN agegr1 = '13-14';
6▶ ELSE agegr1 = '>14';
7▶RUN;

PDV

_N_
1
Name
Alfred
Age
14
Height
69
Weight
112.5
bmi
16.6
agegr1
13-14
age <= 14 is true: agegr1 = '13-14'.

Macro debugger

Find out why a macro does what it does.

Put the cursor on a call and click Debug Macro. Step into nested macros, with the call stack and each macro's variables in view.

The complete tutorial, 5 minutes, recorded on SAS OnDemand: %by_sev and %nobs, line by line. Jump to a chapter:

  1. why the debugger
  2. start it
  3. one line at a time
  4. stop where it matters
  5. look without changing the code
  6. into the called macro
  7. try another path
  8. what ran, how often
  9. debug a call in your program
  10. recap

F10 steps. F11 steps into %nobs.

Breakpoints with conditions in macro language, such as &i. = 3. Open the data sets the paused macro has made so far. After the run, code coverage shows which lines ran.

In the manual

macros.sas · macropaused in %by_sev
1▶%MACRO by_sev(data=adae, sevs=MILD MODERATE SEVERE);
2▶ %LOCAL i sev nrec nsub;
3▶ %DO i = 1 %TO %SYSFUNC(COUNTW(&sevs., %STR( )));
4▶ %LET sev = %SCAN(&sevs., &i., %STR( ));
5▶ DATA _sev; SET &data.; WHERE trtemfl = "Y" AND aesev = "&sev."; RUN;
6▶ %LET nrec = %nobs(_sev);
7▶ PROC SQL NOPRINT; SELECT COUNT(DISTINCT usubjid) INTO :nsub FROM _sev; QUIT;
8▶ %PUT NOTE: &sev.: &nsub. subjects, &nrec. records;
9▶ %END;
10▶%MEND by_sev;

Macro variables

i
3
sev
SEVERE
nrec
2
nsub
2

Call stack

  1. by_sev
i = 3: sev = SEVERE.
The call %by_sev with its arguments in the call pane, above the macro definitions in macros.sas
Debug Macro on a call: your call, with its arguments, goes into the call pane.
The macro debugger inside %nobs, called from %by_sev, with both macros on the call stack
Inside %nobs, called from %by_sev: both on the call stack.

%pry

Freeze a run where you want to look.

Write %pry into your program. When the run reaches it, it waits: the macro variables, the data sets and the code around it, as they are at that moment. Then let it go on. No more %PUT &=i;, MPRINT and running the whole program again.

The complete tutorial, 7 minutes. Jump to a chapter:

  1. why %pry
  2. your first %pry
  3. the data at the stop
  4. how did I get here
  5. move through the run
  6. try the fix first
  7. stop at the first ERROR
  8. in a DATA step
  9. between steps
  10. the commands
%pry(when=&age. = 14)
Stops only when the condition holds. In a macro, a DATA step or between two steps.
%pry(rescue=Y)
Stops right after the first step that ends with an ERROR, with everything as it was.
ls · vt work.class_m
The macro variables. The data set as it is now. where and freq look into it.
F4 at the stop
Write a test program in the editor, with autocomplete, and run it right there.
c · next
c lets the run go on. next runs one more line or step and stops again.
In the manual
%pry: a breakpoint in the code

Four short films

Stop where you write it, look at data and macro variables.
Write code at the stop, with autocomplete, and run it there.
Developing a macro: why does CRP count only 3 of 5 values?
In a DATA step: stop only for the rows where age > 14, look at the row, step, go on.

SAS server

Your computer and the SAS server, side by side.

Edit the programs on the server as if they were on your own computer. Or keep them on your computer: before each run, DataStep Studio copies what changed. The File Manager moves the rest with one key.

  • F5 F6 F7 F8Copy, move, make a folder, delete. Or drag, or copy and paste.
  • Under a second25 programs, zipped, byte for byte.
  • It asks firstNothing is overwritten or deleted without a question.

Work on the SAS serverThe File Manager

Write

Autocomplete that knows SAS. And your data.

Procedures, options, functions, formats, your librefs, data sets and columns, with the SAS documentation one hover away. Right-click a macro call, and its definition opens.

Autocomplete offering a PROC SORT step template

Keyboard macros, as in SAS.

Type sort, merge, ifelse, dupcheck, %nobs or header and press Tab: the code is written in house style. 80 come built in, every one tested on SAS. Import your own .kmf file from the Enhanced Editor.

All 80 with their code

Format SAS Program

One right-click, and it is readable again.

Keywords upper case, names lower case, two spaces per level, one statement per line. Strings, comments, DATALINES and macro text stay untouched, and a word-by-word check makes sure only the layout changes.

Before
data &outlib..adsl(keep=usubjid trt01p bmi bmicat);
set sashelp.class;
usubjid=catx('-', "&study", put(_n_, z3.));
if mod(_n_,3)=0 then trt01p='Placebo';
else if mod(_n_,3)=1 then trt01p='Drug 10 mg';
else trt01p='Drug 20 mg';
   if bmi < 18.5 then bmicat = 'Underweight'; else if bmi < 25 then bmicat = 'Normal'; else bmicat = 'Overweight';
run;
%summ(indat=adsl, var=age bmi, byvar=trt01p, outdat=summary_by_treatment, dec=1, title=Age and BMI by treatment group)
After
DATA &outlib..adsl(KEEP=usubjid trt01p bmi bmicat);
  SET sashelp.class;
  usubjid = CATX('-', "&study.", PUT(_N_, Z3.));
       IF MOD(_N_, 3) = 0 THEN trt01p = 'Placebo';
  ELSE IF MOD(_N_, 3) = 1 THEN trt01p = 'Drug 10 mg';
  ELSE                         trt01p = 'Drug 20 mg';
       IF bmi < 18.5 THEN bmicat = 'Underweight';
  ELSE IF bmi < 25   THEN bmicat = 'Normal';
  ELSE                    bmicat = 'Overweight';
RUN;
%summ(
    indat  = adsl
  , var    = age bmi
  , byvar  = trt01p
  , outdat = summary_by_treatment
  , dec    = 1
  , title  = Age and BMI by treatment group
)

Prefer to watch?

Every feature in two minutes.

Every feature in two minutes.
DataStep Studio in one minute.
The study of the book, from SDTM to ADSL, BDS, ADAE, ADTTE, tables and delivery

Learn SAS

A free book that teaches SAS in DataStep Studio.

SAS for Clinical Programmers: the 20% of SAS that does most of the daily work in a clinical trial, on the public CDISC pilot study. About 130 programs, each one run in DataStep Studio, with the log you should see and exercises with answers.

Part VI is about working in DataStep Studio: the daily loop, both debuggers, %pry, and five real workflows with videos.

Read the book, free

Editions

Community is free. Professional is free during Early Access.

CommunityAlways free
  • All run modes, SAS Log, Suspicious Log, SAS Output
  • Data viewer with filters and WHERE keys
  • Libraries, Variables, Options, Created Files
  • SAS Server window and project sync
  • Autocomplete, documentation on hover, parameter hints
  • Format SAS Program
  • Keyboard macros as in SAS (80 built in), import your .kmf files
  • Run in Batch, Stop SAS, the keys you know from SAS
ProfessionalFree during Community Early Access
  • DATA step debugger
  • Macro debugger with code coverage
  • Smart code: step templates, value lists, your macro calls
  • Enlarge and Optimize macro calls
  • Git on the SAS server
  • File Manager: your computer and the SAS server side by side
  • %pry and the SAS Pry terminal

During Community Early Access, all Professional features are available free of charge. Early Access is temporary. Professional functionality may require a paid license following the Early Access period. Free Community functionality will remain available. Nothing to sign up for: install it and every feature is on.

Install

From nothing to your first run in about five minutes.

  1. Install

    In VS Code: Extensions (Shift+Cmd+X), search DataStep Studio, Install. Or paste into Quick Open (Cmd+P):

    ext install datastep-labs.datastep-studio
  2. Check Setup

    DataStep Studio: Check Setup finds Java and Python and installs SASPy with one click.

  3. Connect

    Add New Connection Profile: SAS OnDemand (your region and user ID) or a SAS 9.4 server (host, port, user). The password goes to your system's keychain.

  4. Run

    Open a .sas file and press F4. The manual is inside VS Code: DataStep Studio: Open Manual.

Or with one command in a terminal. It installs the extension, checks Java, Python and SASPy, and names the next step for your computer.

curl -fsSL https://datastep-studio.pages.dev/install.sh | sh
irm https://datastep-studio.pages.dev/install.ps1 | iex

The first for Mac and Linux, the second for Windows (PowerShell; new there). Manual, 2.6.

Installation, step by step: from the Marketplace to both debuggers.
With one command: it installs the extension, reports what your computer still needs, and shows how to connect with your own SASPy configuration.

Step by step, with pictures: Get started, the user manual and the how-to guide. Needs VS Code 1.85 or newer, Java 8 or newer and Python 3.8 or newer, and a SAS OnDemand for Academics account or a SAS 9.4 server that SAS Enterprise Guide connects to (IOM). Works next to the official SAS extension.

Privacy

Your data stays yours.

DataStep Studio collects nothing: no telemetry, no usage data. Your programs, data sets and logs go only to your own SAS session. Your password is kept in your system's keychain.

Something not working? See Troubleshooting in the manual. Questions and feedback: Q & A on the Marketplace or the DataStep Studio thread in the SAS Community.

Questions

Does it work with a SAS 9.4 server at my company?

It is built for SAS 9.4 Workspace Servers (IOM), the connection SAS Enterprise Guide uses. So far it has been tested with SAS OnDemand for Academics, which uses the same technology. Reports from company servers, Windows and Linux are very welcome.

What about SAS Viya?

Not yet. SAS Viya needs a different connection, and the debuggers rely on features Viya does not offer in the same way.

Can I use it next to the official SAS extension?

Yes. While the official extension is installed, DataStep Studio leaves F3 and F8 to it and runs code with F4 and Cmd/Ctrl+Enter.

Does it change my programs?

Only when you ask: Format SAS Program lays out the program you right-click. Running and debugging never change your files.

Cursor, VSCodium or Windsurf?

These editors use another extension store. Download the extension from its Marketplace page (Download Extension) and install the .vsix file with Extensions: Install from VSIX.

What happens after Early Access?

Community stays free. Professional features may require a paid license after the Early Access period; the extension tells you before that happens.