Examples of DATA Step Programs


Example of DATA Step Program: Quality Control Application

This example illustrates how to use a stored compiled DATA step program for a simple quality control application. This application processes several raw data files. The source program uses the fileref DAILY in the INFILE statement. Each DATA step that is used to execute the stored program can include a FILENAME statement to associate the fileref DAILY with a different external file.

The following statements compile and store the program:

 libname stored '  SAS-data-library-1'  ;  data flaws / pgm=stored.flaws;     length Station $ 15;     infile daily;     input Station $ Shift $ Employee $ NumberOfFlaws;     TotalNumber + NumberOfFlaws;  run; 

The following statements execute the stored compiled program, redirect the output, and print the results:

 libname stored '  SAS-data-library-1'  ;  libname testlib '  SAS-data-library-2'  ;  data pgm=stored.flaws;     redirect output flaws=testlib.daily;  run;  proc print data=testlib.daily;     title 'Quality Control Report';  run; 
Output 30.4: Quality Control Application Output
start example
 Quality Control Report                                 1                                                Number      Total  Obs      Station        Shift    Employee    OfFlaws     Number   1     Cambridge          1        Lin          3           3   2     Northampton        1        Kay          0           3   3     Springfiled        2        Sam          9          12 
end example
 

Note that you can use the TITLE statement when you execute a stored compiled DATA step program or when you print the results.




SAS 9.1 Language Reference. Concepts
SAS 9.1 Language Reference Concepts
ISBN: 1590471989
EAN: 2147483647
Year: 2004
Pages: 255

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net