How to run SAS in the Researcher Workbench

  • Updated

SAS Studio is available as an integrated application on the All of Us Researcher Workbench. 

The SAS Studio application in the Researcher Workbench connects to a SAS server in order to process SAS commands. The SAS server is hosted in a cloud environment. After code is processed by the SAS server, the results are returned to the SAS app in your workspace.

In this article, we will describe how to use SAS Studio in the Researcher Workbench and give step-by-step instructions to start the SAS app, save your data, manage programs, and stop the app.

To learn more about exporting a dataset into the SAS app, please read Using the Cohort and Dataset Builders with SAS Studio. To learn more about working with data in SAS, see Exploring All of Us data using SAS. 

Explore SAS Studio in this Featured Workspace - You can explore more about SAS Studio in this tutorial workspace (Researcher Workbench login required). To access the contents of the SAS Studio tutorial, please duplicate the workspace, then start a SAS Studio app in your duplicated workspace to launch. It will not render a full preview in the Featured Workspace 'Analysis' tab. Please note all mark down is indicated in green within the tutorial workspace. 

Table of Contents

SAS on the cloud

SAS Studio runs on a virtual machine (VM) or clusters of machines in your workspace cloud analysis environment. The SAS cloud environment on the Researcher Workbench is a VM with 4 CPUs, 15 GB RAM, and 250 GB of disk space and is not customizable.

Cloud Storage Options

There are two dedicated storage locations when using SAS on the cloud: the persistent disk and the workspace bucket.

The persistent disk is created when you start the SAS app, and it is attached to the cloud environment. The persistent disk can be saved even if you stop the cloud environment, and it can be re-attached to your next cloud environment in the workspace. The data on your persistent disk is not shareable and is only available to the researcher who created the SAS app. Read Persistent Disk: Managing & Deleting for information related to persistent disks.

Using the workspace bucket is helpful for saving your work and sharing your work with workspace collaborators. Data can be copied by the owner of the persistent disk to a shareable workspace bucket. It is possible to migrate files from the persistent disk to the workspace bucket as outlined in the section File synchronization between the workspace bucket and the persistent disk.  

Cloud Cost

The cost of running SAS on the cloud within the Researcher Workbench depends on the length of time you run the app and the size of the data that you store within your workspace bucket and/or persistent disk. The SAS app costs $0.40 per hour while running. The persistent disk associated with the SAS app is $10.00 a month. You can estimate costs by reading the article: What exactly am I paying for?

You will be charged from the time you first start the SAS app until it’s been deleted. You can save your work on your persistent disk or workspace bucket and create the app again when you are ready to use SAS again.

Saving your work

When using SAS Studio you may save various files, to include .csv, .txt or .sas7bdat files for later use. Files can be saved to the persistent disk or the workspace bucket. Within your workspace bucket, you can share your work with workspace collaborators.

Some features to note when you are saving files from your SAS app are as follows.

SAS Programs

When you create and save SAS programs (.sas), these files are automatically saved to your workspace bucket as long as you save them under the Home folder in the Explorer tab highlighted below. If you save a SAS program in a subfolder, it will not be synced to your workspace bucket.

Image 1.png

Each time you delete and re-create your SAS application, your SAS programs will be visible in the SAS UI. There are more details available in the instructions found in the section Managing SAS Programs. You can learn more about workspace buckets in the articles: Accessing Files in the Workspace Bucket or Persistent Disk and How do I access the workspace bucket and copy data to and from it?

Other Files

A persistent disk is created alongside your SAS application. When you delete your SAS application, you have the option to save your persistent disk, which we recommend if you are following the instructions in this guide for importing datasets.

Anything you save to your ‘sas-analytics-pro/Home’ folder will be saved on your persistent disk, including .csv and .sas7bdat files. If you keep your persistent disk, when you delete your SAS environment, it will automatically be re-attached to the next SAS environment you create. Your .csv files and your .sas7bdat files will still be available in the ‘sas-analytics-pro/Home/’ folder when you re-create SAS. Note: If you create a subfolder under your home folder, your subfolder will not be saved to your persistent disk. 

You can learn more about persistent disks in the article Storage Options Explained – User Support

Starting SAS

To start the SAS app, you will need to connect to a SAS server on the cloud. 

1) Open a workspace or create a new workspace.

2) Select the SAS Cloud Environment icon on the right hand menu of your workspace. The SAS Cloud Environment information screen will open.

Note: The SAS cloud environment is not customizable.

3) Choose whether or not you want to select the auto-delete option.

4) Select Start at the bottom of the SAS Cloud Environment information screen to launch the SAS app.

image 2.png

Opening SAS 

5) After a short time, the SAS app will be active. To verify that the app is running, you will see a green circle on the SAS app icon in the right hand menu. You can also check the status of your SAS app creation by selecting the thunderbolt icon.

6) Once your SAS app is running, select Open SAS from the bottom right corner of the SAS Cloud Environment information screen to open the application.

image 3.png

There are multiple ways to open the SAS application. You can select Open SAS in the Applications information screen or the SAS Cloud Environment information screen. Additionally, when previewing an SAS file in the Analysis tab, the application will open when you select Edit.

The auto-delete option

When you start the app, you can opt-in to use the auto-delete function, which will automatically delete your SAS application if left idle for a set period of days. You opt-in by checking the box within the SAS Cloud Environment information screen. You can only enable auto-delete before starting your application.

There are multiple options available for the idle period before your application will be deleted, including 1, 3, 7, 8, 15, and 30 days. Your persistent disk will not be deleted. The time counts down when you do not have an active SAS app open. We recommend that you use auto-delete if you are concerned about incurring costs by leaving the app running in the background.

image4.png

Managing SAS Programs

A SAS program is a set of instructions written in the SAS programming language that tells the SAS software what actions to perform. These programs are used for data analysis, statistical modeling, and data manipulation. Each step in the program performs a specific task. Only two kinds of steps make up SAS programs: DATA steps and PROC steps.

A DATA step enables you to manage and manipulate your data. You typically use a DATA step to read data from an input source, process it, and create a SAS table.

A PROC (procedure) step enables you to model, analyze, visualize and present your data. PROC steps include a library of prewritten routines (procedures) that perform specific tasks on SAS tables, such as listing, sorting, and summarizing data. To learn more about SAS programs, watch the Writing a Basic SAS Program video.

Create and save a SAS program

To create and save a SAS program within SAS Studio: 

1) Open a SAS app following the instructions in the section Starting SAS

2) Within your SAS environment select New from the top menu → SAS Program, or click the + sign at the top of the coding window 

image5.png

3) Insert the program code you want to save in the box under Code

4) Select the save icon to name and save your program.

image6.png

5) To specify the program location, navigate to the location you want to save your SAS Program within the ‘sas-analytics-pro/Home’ folder, and click Save. Note: If you create a subfolder under your home folder, your subfolder will not be saved to your persistent disk. 

image7.png

6) After you successfully save the program, you will see your .sas program in the Analysis tab of your workspace. These program files will be automatically saved to your workspace bucket. To view files in your workspace bucket, you can navigate to the 'ABOUT' tab of your Workspace, click the 'File management' and view the files in your workspace bucket directly with Google's Storage interface. 

image8.png

Open a SAS program

1) To open a specific SAS program you created, open a SAS application following the instruction found in the section Starting SAS.

2) In an active SAS app select Open from the top menu or click on the Explorer tab in the left ribbon. 

image9.png

3) Navigate to the ‘sas-analytics-pro/Home’ directory and double-click the program you want to open in SAS. This program will open within the SAS Studio UI.

Note: Unlike Jupyter notebook, you cannot yet open a SAS program directly from the Analysis tab in your workspace. 

image10.png

Please note: If you and a collaborator are in the same workspace, we do not recommend editing or using the same SAS program at the same time. This may cause you to overwrite each other, potentially losing any progress. 

Importing data as tables in SAS Studio

In the following instructions, you will use the SAS application to create, save, and export files.

Much like other features of the Researcher Workbench, the SAS app allows you to bring in external files for analysis. Please review the article How to Comply with All of Us Policies When Importing Data into the Researcher Workbench prior to importing your own files into the Researcher Workbench. 

Import files into SAS 

1) Select the Explorer tab on the left menu and right click on Home and select Upload File.

image11.png

2) Drag and drop the file you wish to upload or click the + at the top of the window and navigate to the file you wish to upload. Then click Upload. Note: You can upload multiple files at once.

image12.png

Convert an uploaded file into a SAS table

To convert an uploaded file (e.g. csv into a SAS table), you will export that file into a Library.

1) If you have an existing library you want to output the data to, skip to step 2. If you want to create a new library:

a. Select the Explorer tab on the left menu and right click on Home and select Create Library. 

image13.png

b. Name your new library.

image14.png

c. Your new library name will appear under Libraries on the right hand menu.

image15.png

2) Click the Explorer tab in the left ribbon, right-click on the uploaded file, then click Import Data

image17.png

3)  Specify the Library you want to output the data to and name your new Table.

a. Location is set by default if you click ‘Import data’ on a specific file.

b. Library is where the data will be stored. 

c. Table is the name of the data. 

d. Note: SAS will automatically generate code to import the data based on the “Source” and “Output” specifications.

4) Click the Run icon at the top left of the code pane.

image18.png

5) Your new dataset will now be available from both the Explorer tab and the Library tab

a. Navigate to Explorer (on the left menu bar) → ‘Home/sas-analytics-pro’ → double click on your data set to check if it was imported correctly OR 

b. Navigate to Libraries (on the left menu bar) → “MY_LIB” (or the Library where you saved) → double click on your data set to check if it was imported correctly.

image19.png

image20.png

6) Following these instructions will save your .sas7bdat file and your imported .csv to your persistent disk automatically. If you save your persistent disk when you delete your SAS application, this file will still appear in your Explorer tab when you re-create your SAS application.

Note: Your libraries are not automatically saved when you delete and re-create your SAS application, even if you save your persistent disk.

File synchronization between the workspace bucket and the persistent disk

You can view files in your workspace bucket and on your persistent disk via the SAS PIPE feature following the instructions below. 

Your .sas programs will be automatically saved to your workspace bucket. Any other files you save to your /sas-analytics-pro/home folder will be automatically saved to your persistent disk.

Note: Items within subfolders within your home folder will not be saved to your persistent disk.

View files in the workspace bucket and persistent disk

If you want to list the files in your workspace bucket, run the following code snippet in a SAS program:

filename foo pipe "gsutil ls $WORKSPACE_BUCKET" ;
data null;
infile foo ;
input ;
put _infile_ ;
run;

You will see all of your files on the right side. 

If you want to list the files in your SAS persistent disk, run the following code snippet in a SAS program:

filename foo pipe "ls /data";
data null;
infile foo ;
input ;
put _infile_ ;
run;

Move files between workspace bucket and persistent disk

To move a file from your SAS persistent disk to the workspace bucket, you will run the following command. You will update “/data/Program.sas“ to the file name you want to move from your SAS persistent disk. If you want to specify a location in your workspace bucket for the file, you can do so by appending a folder to the workspace bucket variable. For example, if you want to move a program into your /notebooks folder, you would update $WORKSPACE_BUCKET to $WORKSPACE_BUCKET/notebooks

filename foo pipe "gsutil cp /data/Program.sas $WORKSPACE_BUCKET" ;
data null;
infile foo ;
input ;
put _infile_ ;
run;

To move a file from your workspace bucket to your SAS persistent disk, you will run the following command. You will update “$WORKSPACE_BUCKET/Program.sas“ with the path of the file you want to move to your persistent disk from your workspace bucket.

filename foo pipe "gsutil cp $WORKSPACE_BUCKET/Program.sas /data/" ;
data null;
infile foo ;
input ;
put _infile_ ;
run;

Saving a SAS visualization

When you have created a visualization in SAS, click on the ‘Results’ window. Right-click on the image, and click save. This will download the image to your local PC. Prior to downloading any objects from SAS, please ensure you are in compliance with our Data and Statistics Dissemination Policy, and have review our Egress Policy

imag24.png

Policies for downloading data from SAS 

While it is possible to download data from SAS, please remember that all downloads and dissemination of data must comply with the Data User Code of Conduct and the Data and Statistics Dissemination policy

As a reminder, per the Data User Code of Conduct, registered users of the Researcher Workbench are not permitted to download or remove participant-level data from the platform. Refer to our Egress Alert Policy article for more details: Egress Alert Policy – User Support

An egress alert will be issued when a registered researcher violates certain security policies put in place by the All of Us Research Program’s Data and Research Center (DRC).

Stopping the SAS app

When you are finished using the SAS app, we recommend that you save all of your work in your workspace bucket and then stop the application by deleting the cloud environment. Pausing the SAS cloud environment is not available. Note: If you do not delete your SAS app or set an auto-deletion setting as mentioned in the section on the auto-delete option, you will continue to be charged for a running SAS app. 

1) Click on the cloud and thunderbolt Applications icon in the right hand menu.

2) In the SAS active applications menu, click on the trash to delete the cloud environment.

image21.png

3) Additionally, you can open the SAS cloud environment panel by clicking on the SAS icon in the right hand menu. At the bottom left of the panel, select Delete Environment.

image22.png

You have two delete environment options:

a. Keep persistent disk, delete environment. If you keep your persistent disk, you will incur a cost of $10.00 a month. The persistent disk will be saved and opened the next time you start a SAS cloud environment.

b. Delete persistent disk and environment. Your persistent disk and environment will be deleted. Only data that is within your workspace bucket will be saved.

We recommend keeping your persistent disk when you delete your SAS application or ensure datasets are saved to the workspace bucket.

image23.png

Other helpful materials

To open datasets from the Cohort and Dataset Builders with SAS, read Using the Cohort and Dataset Builders with SAS. For additional information and instructions on working with data in the SAS app, see Exploring All of Us data using SAS

To learn more about SAS, please see these articles within SAS support and SAS communities:

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Article is closed for comments.