Home » SAS Program Structure

SAS Program Structure

by Online Tutorials Library

SAS Program Structure

In the last topic, we studied the SAS User Interface, and in this topic, we are going to discuss the SAS Program Structure. To understand the SAS Program Structure first, you should have clarity of SAS User Interface.

The programming structure of SAS consists of three significant steps: the first is the data step, the second is a PROC step, and the third is an output step. Other than these steps programming structure also includes data set, label, variables, values, and run.

SAS Program Structure

Before analyzing the data, you should have the SAS to read your data, and your data must be in the form of a dataset. SAS dataset is used to organize data values in a tabular form, i.e., in the form of rows and columns. Let’s understand the purpose of all steps via example.

Syntax of the SAS program:

1. The Data Step

Data step includes the creation of data sets which becomes a source of data analysis. DATA step begins with keyword DATA, to which we have to give a name and this name is the name that denotes the SAS data set.

Syntax:

Let’s understand via example.

In the above example, the data step begins with the data set that is “Weight” and ends up with the assignment of values to the variable liters. It is mandatory to write data when declaring data set.

SAS DATA phase fulfills the following purposes:

  1. It sends input data (the values given to a variable) into the dataset.
  2. Loads required data sets into SAS memory.
  3. Data manipulation such as modifying and updating data in SAS data sets.
  4. It does checking and correction of errors.
  5. Merge and update old data sets to create new data sets from the existing data set.

2. The PROC step

PROC step analyses data of data sets. All procedures in SAS begin with a PROC statement, in which the name of the procedure (MOD, PRINT, PROC MEANS or PROC SORT, for example) is named just after the keyword PROC.

Syntax:

SAS DATA phase fulfills the following purposes:

In the PROC step, the SAS inbuilt procedure (like MOD, PRINT, PROC MEANS, etc.) gets invoked to analyze the data.

Let’s understand via example:

In the above example, “PROC print data=student” is a PROC step in which PROC is a keyword and print data is a procedure.

3. The Output step

Output step displays the result of the data analysis done in the PROC step. The RUN statement is the statement responsible for generating output, but it is neither a part of the data step nor the PROC step.

Syntax:

Let’s understand via example:

Output:

SAS Program Structure

So this is all about the SAS program structure. We have given a detailed explanation in a very clear way but if you still have any doubt, feel free to ask in our contact section.


Next TopicSAS Data Set

You may also like