Health Research Analytics
Getting Started with SAS Studio
Learning Objectives
-
Understand the basics of the SAS Studio interface and workflow
-
Learn how to create, organize, and manage folders and libraries
-
Import datasets into SAS for analysis using built-in tools and sample files
Why Use SAS Studio?
SAS Studio is a powerful, web-based statistical software that is widely used in health research. It offers both a user-friendly point-and-click interface and a programming environment, making it accessible to both beginners and advanced users. While several statistical software packages exist (e.g., R, Python, SPSS, Stata, MATLAB, and Excel), SAS remains a preferred choice in healthcare settings.
Key Benefits of SAS Studio:
-
Dual Functionality – Offers both a point-and-click interface and a coding environment for flexibility.
-
Web-Based Access – Runs in a browser, so you can access your data from anywhere.
-
Regulatory Compliance – Popular in healthcare for its built-in data security measures.
-
Free Access – The OnDemand for Academics version provides essential features at no cost.
Setting Up SAS Studio
​
Access SAS Studio:
-
Open your web browser and search for SAS OnDemand for Academics.
-
Click on Access Now, then sign in or create an account.
-
After creating your account, return to the sign-in page and sign in and then Launch SAS Studio.
Understanding the Interface:
Navigation Pane (Left Panel)
​
-
Server Files and Folders – Manage files and datasets.
-
Task and Utilities – Point-and-click tools for data analysis.
-
Snippets – Pre-written code templates for efficiency.
-
Libraries – Reference to the storage locations for datasets.
Work Area (Main Panel)
​
-
Code Editor – Write and run SAS programs.
-
Log Tab – Displays execution details, warnings, and errors.
-
Results Tab – Shows outputs, including tables and graphs.
-
Output Data Tab – Displays created or modified datasets.

Click for a bigger image
Managing Data in SAS Studio
Creating a folder
​
-
Click on Server Files and Folders in the navigation pane.
-
Right click on Files (Home) → New → Folder.
-
Name the Folder ‘FHS’ (for Framingham Heart Study – the dataset will be using in this course. More on that shortly) and save.
​
Creating a Library
​
In SAS, a library is a reference (shortcut) to a folder used to:
​
-
Store existing datasets, or
-
Save new outputs from your analyses.
Creating a library simplifies dataset management and helps SAS quickly locate and access your data.
Method 1: Creating a Library Using the Wizard
​
-
Locate the Folder:
-
Right-click on your newly created FHS folder.
-
Select Create → Library.
2. Name the Library:
-
Enter FHS_Lib in the name field of the pop-up window.​
​​
Two rules for naming a library:
1. Only ≤8 alphanumeric or _
2. First character cannot be a number
3. Ensure Library Persistence:
-
Check the option: "Re-create this library at start-up."
​
4. Click the Run button to execute the code.
​
Method 2: Creating a Library Using SAS Code
-
Create a New SAS Program:
-
Navigate to Server Files and Folders → New → SAS Program (or press F4).
-
​
​​​​​​​​To find the path to your folder, right click on the ‘FHS’ folder à Properties à Copy the location à Close à paste within quotes as follows:
​
libname FHS_Lib "/home/youraccount/FHS”;
​​
(Note: Do not forget a semi colon ; at the end every SAS statment)
​​​​​​ 2. Enter the SAS Code:
​
libname FHS_Lib "pathtoyourfolder";
Replace “pathtoyourfolder” with the exact path to your FHS folder​
​​​​​​​​
​ 3. Save the program as Heart.sas in FHS folder.
4. Click the Run button to execute the code.
Automatically Running the Code at Startup in SAS
To ensure SAS automatically runs the libname statement each time you start a new session, follow these steps:
​
-
Click on More Application Options (three-dot icon at the top-right corner of main panel).
-
Select Edit Autoexec File from the dropdown menu.
-
In the popup window titled “Specify the SAS statements to run when the application starts”, enter the following code: libname FHS_Lib "/home/youraccount/FHS";
-
Click Save.
​​
Organizing Folders and Libraries in SAS Studio
​
Small Datasets:
​
When working with small datasets, it is often convenient to create a new folder for each project and assign a corresponding SAS library that references that folder. This keeps your data, code, and outputs neatly organized in one place.
Large Datasets:
​
However, for large datasets, storing multiple copies across different folders can be inefficient and unnecessary. In such cases, a more efficient approach is to:
-
Create a single folder to store the large dataset
-
For each new project, create a separate project folder
-
In your SAS code, assign:
-
One library to the master dataset folder (for read-only access)
-
Another library to the project folder (for outputs and derived datasets)
-
This approach reduces storage redundancy, ensures consistency across projects, and maintains a clean workspace.
