SASMacro function (I)
Concept
Put a variable, a paragraphProgramOr a text name for future calls.
SASMacro main functions:
Obtain SAS System Information
SAS Some automatic macro variables are created at startup to store the current SAS The start date, time, version number, and other information of a process. You can use these macro variables under any circumstances.
Conditional execution process step and data step
For example, submit a detailed production report every day and add a summary report every Friday. You can use the macro function to run the same program every day to implement the preceding tasks.
Develop an interactive system
UseSASMacro language% WindowStatements and some basic programming statements can be used to develop an interactive user interface.
Generate data-independent SAS Program, but can display data-related results
Macro function persistenceSASProgram independence and portability. A program can run in multiple cases to obtain the expected results.
In different SAS Transfer Data between data steps or process steps
SASMacro variables can be stored inSASIs referenced anywhere and global, so it becomes differentProcessThe most convenient means to transmit data between them.
Repeated execution SAS Program
Example: Print20Different but regularSASContent in the dataset.
% Macro print;
% Do
Nn = 70% to 89;
Proc
Print DATA = year & nn;
Title
"19 & NN sales data ";
Run;
% End;
% Mend
Print;
% Print;
Where usedSASMacro language variables and language components are both signed%Or&Start. WhenSASAfter the program is submitted, during the compilation phase, the system scans the program word by word.%Or&Start the macro language processor to process the starting word:
Register the definition of macro variables or macro sequences.
The macro variable call is interpreted (Resolve), Calls to the macro program are read into the corresponding source program for compilation.
Compile other macro statements into corresponding programs.
% IncludeStatement
Global Statement, which can appear in any position of the program. Read a piece of text stored in an external file as a program and run it as a program. Usage:% IncludeFile Settings</Source2>
Example: LabelDST ('abc. SAS ')A section in the fileSASProgram:% Include DST ('abc. SAS ');
(To be continued)