![]() Chapter Contents |
![]() Previous |
![]() Next |
Syntax |
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
For complete information about the DATA statement, see SAS Language Reference: Dictionary.
Process |
To compile and store a DATA step program, do the following:
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.
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 |
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;
Partial SAS Log Identifying the Stored DATA Step Program
. . . 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 |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.