Defining New Variables

Contents Index <<Browse<<


Raw data can be manipulated in the datastep. This is often done prior to the analysis of the data using SAS procedures. Here's an example.

In a math course, the course grade is based on the scores on 3 midterms and a final exam. The midterms are worth 20% each; the final worth 40%. On each test 100 points are possible. Here's an example of a datastep which inputs data and computes the course total.

data score;
input last $ first $ m1-m3 final;
total=0.2*m1+0.2*m2+0.2*m3+0.4*final;
cards;
brown susan 75 82 35 88
smith james 22 92 45 97
run;

proc print data=score;
run;

Copy this program into the program editor window, select LOCAL--SUBIMT from the menu there, and see how it runs.

The data set score will contain a variable total which is the weighted average of the midterm and final exam scores. Note the use of the subscripted variable m to stand for the 3 midterm scores.

The usual trigonometric, exponential, logarithmic, and arithmetic functions are available for use in the data step. The functions topic gives a partial listing of other specialized functions which are available.

This concludes the tutorial. You may wish to begin working on a project to get experience in data step programming and the use of SAS procedures in the analysis of data.


Contents Index <<Browse<<

Copyright © 1997 by Jerry Alan Veeh. All rights reserved.