Creating a Stored Compiled DATA Step Program


Syntax for Creating a Stored Compiled DATA Step Program

The syntax for creating a stored compiled DATA step program is as follows :

DATA data-set- name (s) / PGM= stored-program-name

  • <(< password-option ><SOURCE= source-option >)>;

where

data-set-name

specifies a valid SAS name for the output data set created by the source program. The name can be a one-level name or a two-level name. You can specify more than one data set name in the DATA statement.

stored-program-name

specifies a valid SAS name for the SAS file containing the stored program. The name can be a one-level name, but it is usually a two-level name. Stored programs are assigned the member type PROGRAM in the SAS data library.

password-option

assigns a password to a stored compiled DATA step program.

source-option

allows you to save or encrypt the source code.

For complete information about the DATA statement, see SAS Language Reference: Dictionary .

Process to Compile and Store a DATA Step Program

To compile and store a DATA step program, do the following:

  1. Write, test, and debug the DATA step program you want to store.

    If you are reading external raw data files or if you output raw data to an external file, use a fileref rather than the actual file name in your INFILE and FILE statements so that you can redirect your input and output when the stored program executes.

  2. When the program runs correctly, submit it using the PGM= option in the DATA statement.

    The PGM= option tells SAS to compile, but not execute, the program and to store the compiled code in the SAS file named in the option. SAS sends a message to the log when the program is stored.

Note  

The default SOURCE=SAVE or SOURCE=ENCRYPT options automatically save your source code.

Note  

If you move your application to another operating environment, you need to recompile your source code and store your new compiled program.

Example: Creating a Stored Compiled DATA Step Program

The following example uses the information in the input SAS data set IN.SAMPLE to assign a plant type based on a plant code. Note that the global LIBNAME statements are necessary to identify the storage location for your files, but are not part of STORED.SAMPLE, the DATA step that SAS stores.

 libname in '  SAS-data-library  ';   libname stored '  SAS-data-library  ';   data out.sample / pgm=stored.sample;      set in.sample;      if code = 1 then         do;            Type='Perennial';            number+4;         end;      else      if code = 2 then         do;            Type='Annual';            number+10;         end;      else         do;            Type='ERROR';            Number=0;         end;   run; 
Output 30.1: Partial SAS Log Identifying the Stored DATA Step Program
start example
 .   .   .   NOTE: DATA STEP program saved on file STORED.SAMPLE.   NOTE: A stored DATA STEP program cannot run under a different operating system.   NOTE: DATA statement used:         real time           1.14 seconds         cpu time            0.12 seconds 
end example
 



SAS 9.1.3 Language Reference. Concepts
SAS 9.1.3 Language Reference: Concepts, Third Edition, Volumes 1 and 2
ISBN: 1590478401
EAN: 2147483647
Year: 2004
Pages: 258

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