%PUT macro statement

From sasCommunity
Jump to: navigation, search
This is a work in progress. You can contribute to this article.

The %PUT macro statement or %PUT statement is a SAS macro language statement that displays text or the values of macro variables in the SAS log.


%PUT text ;


%PUT type of macro variable ;
  • text is the text to be put into the SAS log. The text can include macro variables, macro quoting functions and escaped characters. However, leading and trailing blank spaces surrounding the text are ignored. If text is omitted then a blank line is put in the SAS log.
  • type of macro variable can be one of the following identifiers.
    • _ALL_
    • _GLOBAL_
    • _LOCAL_
    • _USER_
    • _READONLY_ (Only in SAS 9.4)
    • _WRITABLE_ (Only in SAS 9.4)


The %PUT macro statement can be used in open code. It is often used when debugging a program to reveal the values contained in macro variables or to confirm that a program has reached a particular point in processing.

If some or all of the text is contained in another macro variable then that macro variable name needs to be preceeded by an ampersand symbol (&). If both the macro variable name and value are to be displayed in the SAS log then preceeding macro variable name with both an ampersand symbol and an equals sign (&=) produces macro_name = value in the log.

Also, a macro variable name needs to be followed by a period (.) if there is no trailing space or other character that identifies the starts of a new token. This is so the macro language parser can tell where the macro variable name ends, so it will not misinterpret trailing text as part of the macro variable name. The trailing period at the end of any macro variable name is considered part of the name. If a period needs to be displayed immediately after the the text contained in the macro variable then the the macro variable name needs to be immediately followed by two (2) periods, rather than one.

Various quoting and unquoting macro functions can also be used in the text to hide characters from the parser (or tokenizer), so they can be printed to the log as text.

Alternative functionality

Not quite what you are looking for? There are several other statements and functions that have a similar functionality to the %PUT macro statement:

Further reading

sasCommunity articles

SAS Documentation

  • SAS Macro Language: Reference: %PUT Statement - Versions: 9.2, 9.3, 9.4

See also