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.
or
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 proceeded by an ampersand symbol (&). If both the macro variable name and value are to be displayed in the SAS log then proceeding 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.
This article was originally posted by Cameron on sasCommunity.org.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.