Skip to content

Set up DataStep Studio and the data

You need three things: a free SAS session, an editor that shows you what SAS does, and the data. Plan about 10 minutes, once.

Watch the whole path first: install, Check Setup, profile, first run, both debuggers. The video was recorded in a fresh VS Code with nothing installed.

  1. Get a SAS OnDemand account. Register at welcome.oda.sas.com. Write down your user ID and your region. The account is free for learning.

  2. Check Java and Python. In a terminal, type java -version and python3 --version (Windows: py --version). You need Java 8 or newer and Python 3.8 or newer. Missing? Java: Eclipse Temurin from adoptium.net. Python: python.org.

  3. Install DataStep Studio. In VS Code, open the Extensions view (Shift+Cmd+X on a Mac, Shift+Ctrl+X on Windows), search for DataStep Studio and click Install.

  4. Run Check Setup. Open the Command Palette (Shift+Cmd+P or Shift+Ctrl+P) and run DataStep Studio: Check Setup. If SASPy is missing, click Install SASPy.

  5. Connect. Run DataStep Studio: Add New Connection Profile, choose SAS OnDemand, and enter your region and user ID. Your password is asked at the first run and kept in your computer’s keychain.

These pictures come from a test run on a computer with no SASPy and no SAS configuration, the situation of a new user.

DataStep Studio for SAS on the Marketplace page in VS Code, with the Install button

Step 3: the Marketplace page. Publisher DataStep Labs; click Install.

Check Setup: Java 17 and Python 3.12.3 found, SASPy missing, with an Install SASPy button

Step 4: Check Setup finds Java and Python and sees that SASPy is missing. Click Install SASPy. It goes into DataStep Studio’s own Python environment and does not change your Python.

The message SASPy is installed

A few seconds later: “SASPy is installed.” Now add the connection profile.

Choosing the SAS OnDemand home region Europe 1

Step 5: choose your home region. It is the region SAS OnDemand shows next to the house icon after you sign in, for example Europe 1.

Typing the SAS OnDemand user ID, here an example address

Then your user ID (an example here). Not sure what it is? The e-mail address you sign in with also works. Then press Enter for the profile name and click Connect Now. A masked box asks for your password once.

DataStep Studio connected: the Libraries tab lists WORK, SASHELP and the other libraries

Connected: the Libraries tab lists your SAS libraries. In the test run this took 4 seconds after the password.

Prefer one command? Mac or Linux: curl -fsSL https://datastep-studio.pages.dev/install.sh | sh. Windows PowerShell: irm https://datastep-studio.pages.dev/install.ps1 | iex.

The keys you need in this book:

KeyWhat it does
F4Run the selection, or the whole program
Ctrl+Alt+UpRun from the top down to the cursor
F12Open the data set the last step created
F10 / F5In the debugger: run one statement / run to the next breakpoint

Every program in this book is in one file: sas-book-programs.zip. Unzip it into your sasbook folder. The programs are numbered by chapter (04_first_last.sas belongs to chapter 4), and within a chapter the file order is the run order. There is no macro library to install: every macro the book uses is written in the book, in the chapter that needs it.

Every program in the zip ran in DataStep Studio on SAS OnDemand, all in one session and in file order, before this book was published.

Create a folder sasbook on your computer, save this program as 00_setup.sas, and press F4. It downloads the CDISC pilot study (SAS transport files from the PHUSE scripts repository, MIT licence) and copies it into two libraries.

00_setup.sas
/* Book setup: download the CDISC pilot study once and assign two libraries */
%LET book = %SYSGET(HOME)/sasbook;
%LET src = https://raw.githubusercontent.com/phuse-org/phuse-scripts/master/data;
OPTIONS DLCREATEDIR;
/* DLCREATEDIR creates one folder level only, so create the parent first */
LIBNAME book "&book.";
LIBNAME sdtm "&book./sdtm";
LIBNAME refadm "&book./refadam";
LIBNAME xptdir "&book./xpt";
LIBNAME xptdir CLEAR;
LIBNAME book CLEAR;
%MACRO getxpt(kind, mem, lib);
%LOCAL xpt;
%LET xpt = &book./xpt/&mem..xpt;
%IF NOT %SYSFUNC(FILEEXIST(&xpt.)) %THEN %DO;
FILENAME dl "&xpt.";
PROC HTTP URL="&src./&kind./cdiscpilot01/&mem..xpt" METHOD="GET" OUT=dl; RUN;
FILENAME dl CLEAR;
%END;
LIBNAME inxpt XPORT "&xpt.";
PROC COPY IN=inxpt OUT=&lib. MEMTYPE=DATA; RUN;
LIBNAME inxpt CLEAR;
%MEND getxpt;
%MACRO getall;
%LOCAL i m;
%LET sdtmlist = dm ae cm ds ex lb mh sv vs suppdm;
%LET adamlist = adsl adae adlbc advs adtte;
%DO i = 1 %TO %SYSFUNC(COUNTW(&sdtmlist.));
%LET m = %SCAN(&sdtmlist., &i.);
%getxpt(sdtm, &m., sdtm)
%END;
%DO i = 1 %TO %SYSFUNC(COUNTW(&adamlist.));
%LET m = %SCAN(&adamlist., &i.);
%getxpt(adam, &m., refadm)
%END;
%MEND getall;
%getall

What you should see in the Libraries view:

LibraryData setRecords
SDTMDM306
SDTMAE1191
SDTMEX591
SDTMVS29643
SDTMLB59580
REFADMADSL254
REFADMADAE1191
REFADMADTTE254

You do not need to understand this program yet. Run it once and go on. When you come back after Part I and chapter 8, it reads like this:

  1. %LET stores two texts: the folder in your SAS home and the web address of the data. &book. and &src. use them later.
  2. LIBNAME with OPTIONS DLCREATEDIR creates the folders sdtm, refadam and xpt and points a library name at each.
  3. %getxpt handles one data set. %SYSFUNC(FILEEXIST(...)) checks if the file is already there. If not, PROC HTTP downloads it, like a browser saves a file. Then LIBNAME ... XPORT opens the transport file (.xpt, the file format the FDA asks for), and PROC COPY copies its data set into the library.
  4. %getall calls %getxpt once for each name in two lists, with a %DO loop over the words of the list. Chapter 8 explains such loops.

Because of the check in step 3, a second run downloads nothing. It only copies the data sets again.

REFADM holds the reference ADaM from CDISC. In Part II you build your own ADaM and compare it with this one, the way real validation works.

00_libs.sas
OPTIONS NOCENTER;
LIBNAME sdtm "%SYSGET(HOME)/sasbook/sdtm";
LIBNAME refadm "%SYSGET(HOME)/sasbook/refadam";