Return to main SAS Window

Overview

This document provides general guidelines for writing SAS programs.


The SAS Command File

SAS programs are divided into DATA steps and PROCs. The purpose of the data step is to create one or more SAS data sets. The data step contains statements which read in raw data files or existing SAS data sets. Other data step tasks include transforming, creating, and selecting variables, selecting cases, defining missing data, and providing labels for variables. The data step begins with the word DATA followed by the name of a data set. See Sample Program #1 for an example of a simple data step.

SAS PROCs are used to analyze or graph data or provide information about a SAS data set. For example, PROC REG performs multiple regression on sample data, while PROC CONTENTS tells the user the name and location of the variables in a SAS data set.

A SAS program may contain one or more data steps and/or one or more procedures.

The following texts provide useful information for writing your SAS program:


 

Basic Syntax Rules

The SAS data step consists of a series of statements. Rules for writing these statements follow.

Words:

Variable names:

Statements:


 

The Data Step

    y = sum(of x1-x15) ;
           label y = 'total score' ;
           if y > 10 then group = 1 ;
             else group = 2 ;
           keep group y ;


 

SAS PROCS


Miscellaneous Commands


 

Return to Top of Document