Go BackSAS: DATA Step Programming

Synopsis
SAS: DATA Step Programming describes statements and options available to program various features in the DATA step.

Audience
This course is for end users, programmers and business professionals who have an intermediate level of experience with SAS.

Time
3 - 6 hours

Product Code: SAS104
After completing this course, the student should be able to:
 
Sort a data set and establish sorted variable groups
Use a previously created SAS data set
Use observations in calculations
Create total variables
Use DO groups to control processing
Produce reports using the DATA step
Analyze SAS logs with problems

SAS Review
Reviews basic SAS and course conventions.
 
Course Program

Basic SAS program used as the course example.  The FILE and INCLUDE commands in Display Manager to store and access a program.  Rules for coding SAS.  Syntax and screen design conventions used in the SAS series.

Working with Sorted Data
Describes how to sort a data set in a PROC step and then use it again in a DATA step.  Explains how to establish sorted variable groups which can be used for subtotals and/or totals and for checking the first and last observation.
 
Sorting a Data Set

Using PROC SORT to sort a data set by one or more of its variables.
 
Accessing a Sorted Data Set

Using the special SAS data set name _NULL_ to begin a DATA step but not create a SAS data set.  Reading observations from a SAS data set using the SET statement.  Using the BY statement to establish sorted variable groups.  
 
Using Sorted Variable Groups

Finding the first or last observation in a group using FIRST.variable and LAST.variable.

Accumulating Totals
Describes how to use observations in calculations and how to create total variables.
 
The RETAIN Statement and Sum Statement

Listing variables that should retain their values throughout the DATA step.  Using the sum statement to sum and retain a value.
 
DO Groups Used With Sum Statements

Coding DO, DO WHILE, DO UNTIL and iterative DO statements to control processing.  Using DO groups to maintain subtotals and grand totals.
 
Final Calculations

Calculating averages and assigning the value to a new variable.  Checking each observation to determine highest and lowest values.  Retaining values and assigning initial settings.

Writing Output
Producing reports using the DATA step instead of a procedure.    
 
The PUT Statement

Writing output using the PUT statement.  

What Ifs
Gives practice in analyzing SAS logs to find and correct errors in the SAS program.  
 
Analyzing SAS Logs with Problems

Logs showing results of incorrectly coded SAS statements and omitted parameters.

 

Go Back