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.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.