SAS macro function (I)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.