Macro

Macro

The purpose of the SAS macro language is to generate text which is used in SAS programs; this text can be any valid SAS code: statements, variables, text strings, PROC steps, etc. In its simplest form, a macro variable can be used for text substitution in SAS code.

CALL SYMPUT statement can be used to assign values to macro variables during DATA step execution

CALL SYMPUTX was introduced which automatically removes leading and trailing spaces


SYMGET function is used to retrieve values during DATA step execution (macro variables can also be resolved directly during DATA step compilation).
SYMGET always resolves the macro variable to a text string, even when – as in this case – it contains a valid numeric value

%NRSTR function to indicate that the text inside the parenthesis should be interpreted as text and not macro variables or macro invocations


The %QUOTE and %NRQUOTE functions are used to mask special characters and operators – NRQUOTE also masks the & and %. Unmatched quotes or parentheses must be marked with a leading %.

The %BQUOTE and %NRBQUOTE functions are similar, but unmatched quotes or parentheses do not need to be marked.

%SUPERQ masks everything – it is also the only one of the quoting functions that accepts the macro variable name without the leading ampersand.


EG.
















Ref:
https://docs.google.com/file/d/0B_q1-jZuWTR_S0xfdDAzRndXSWc/edit?usp=sharing

No comments:

Post a Comment