Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 37 ยท Getting Started

What Is SAS? A Beginner's Overview

Learn what SAS is, where it is used (clinical research, banking, insurance), what its main parts are, and how a SAS program thinks about data, before you write any code.

SAS is a software suite and a programming language for working with data. The name originally stood for Statistical Analysis System. It began as a research project at a US university in the late 1960s and grew into the products sold by SAS Institute, founded in 1976. Today people use it to clean data, build reports, run statistical models and automate whole data pipelines.

SAS is strongest in industries where results must be repeatable and auditable: pharmaceutical and clinical research, banking, insurance, government statistics and health care. If you read a job advertisement for a "statistical programmer" or "credit risk analyst", SAS is often on the list. This tutorial teaches the language itself, from a blank file to macros, SQL and reporting.

About this site and SAS. SAS is commercial software and it cannot run inside your browser, so the SAS code in this course is shown as read-only. We only show printed output where we are certain what SAS prints. To let you experiment anyway, many lessons include a small Python stand-in: a clearly labelled model of the idea (for example, how a DATA step walks through rows). Those stand-ins run here and are not SAS.

What SAS is made of

SAS is not one tool but a family. The pieces you will meet most often:

Component What it does
Base SAS The core language: DATA steps, basic procedures, the macro facility, ODS output
SAS/STAT Statistical procedures such as regression, ANOVA and mixed models
SAS/GRAPH and ODS Graphics Charts and plots
SAS/ACCESS Connections to databases (Oracle, SQL Server, Teradata and others)
SAS Viya The cloud-native platform, with in-memory analytics and machine learning
SAS Studio, Enterprise Guide Interfaces for writing and running programs

Everything runs on the same language, so a program you learn on a laptop uses the same ideas on a server with billions of rows.

The four building blocks of the language

A SAS program is built from four kinds of code that cooperate:

  1. The DATA step creates and transforms data sets, one row at a time. It is a real programming language with variables, conditions, loops and arrays.
  2. PROC steps (procedures) are ready-made tools: sort, summarize, print, model, chart. You tell a procedure which data to use and what to do, and it does the work.
  3. The macro language generates SAS code. It is what lets you write a program once and run it for ten countries or twelve months.
  4. PROC SQL lets you use standard SQL queries on SAS data.
flowchart LR
    A["Raw data<br/>(files, databases)"] --> B["DATA step<br/>clean and transform"]
    B --> C["PROC steps<br/>analyze and report"]
    C --> D["Output<br/>(tables, HTML, PDF, data)"]
    M["Macro language"] -.generates code for.-> B
    M -.generates code for.-> C

Figure: the usual flow of a SAS job. The macro language works behind the scenes.

A first look at SAS code

Here is a complete small program. You do not need to understand every word yet, only the overall shape.

SAS
data scores;
   input name $ math reading;
   total = math + reading;
   datalines;
Ana 90 85
Ben 72 80
Cara 88 91
;
run;

proc print data=scores;
run;

The data step builds a table named scores with three rows and four columns (name, math, reading, total). The proc print step prints it. Notice two things that hold for all SAS code: every statement ends with a semicolon, and a step is closed with run;.

How SAS thinks about data

SAS data is rectangular, like a spreadsheet or a database table, but the vocabulary is slightly different:

SAS term Common name
Data set Table
Observation Row
Variable Column
Library Folder or database that holds data sets

A variable is either numeric or character. SAS has no separate date type: dates are numbers (you will see how in Functions and Dates). A missing numeric value prints as a period and a missing character value as a blank.

The most important idea is that the DATA step processes one observation at a time, from top to bottom, running your statements once for each row. This is an implicit loop that you never write. The stand-in below mimics it in Python so you can see the pattern.

Python Python stand-in: the implicit row loop of a DATA step

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Ways to get SAS

  • SAS OnDemand for Academics is a free, browser-based SAS Studio for learners and students. It is the easiest way to practice.
  • Your employer's or university's SAS server or desktop installation.
  • SAS Viya trials and cloud offerings.

Check SAS Institute's site for current terms, since offers change. The next lesson, SAS Interfaces, explains what you will see once you are logged in.

Why learn SAS today

  • Large organizations have decades of working SAS code that must be read, maintained and extended.
  • Regulated fields (for example, submitting clinical data to health authorities) have well-established SAS practices.
  • It handles very large data sets in a controlled, well-documented way.
  • The ideas transfer: DATA steps resemble row-wise programming, PROC SQL is SQL, and macros are code generation.

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which part of SAS processes data one observation at a time?

    The DATA step runs its statements once for each observation, an implicit loop. The macro language generates code instead and PROC SQL works on whole tables.
  2. 2. In SAS vocabulary, what is an observation?

    An observation is a row and a variable is a column.
  3. 3. How are dates stored in SAS?

    SAS has only numeric and character variables. A date is a number that you display with a date format.
  4. 4. Why is the Python code in this course labelled a stand-in?

    SAS is commercial software that does not run on this site. The stand-ins are small Python models of an idea.

Summary

  • SAS is a suite and language for data management, analysis and reporting, strong in regulated industries.
  • Four building blocks: the DATA step, PROC steps, the macro language and PROC SQL.
  • Data is rectangular: data sets hold observations (rows) and variables (columns) of numeric or character type.
  • The DATA step loops over rows implicitly; every statement ends with a semicolon.
  • SAS OnDemand for Academics is a free way to practice.

Next: SAS Interfaces: Studio, Enterprise Guide and Batch