BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Can the %put statement post text to outer file?
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The macro language %PUT statement, as document, "normally" posts / outputs macro processing diagnostic messages, including macro variable values, to the SAS log, however, yes, it is possible to re-direct the SAS-generated log to an external file using PROC PRINTTO.

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
How about just export the specific macro variables that I want instead of the whole log file into external file?
abdullala
Calcite | Level 5
use 'put' statement.
Cynthia_sas
Diamond | Level 26
Hi:
Something similar to this technique might work for you:
[pre]
** Use PROC PRINTTO to get ONLY list of Macro vars;
filename mylog "c:\temp\allmacvars.txt";
PROC PRINTTO log=mylog; run;
%put _all_;
PROC PRINTTO; run;
[/pre]

The PROC PRINTTO steps surround the %PUT _ALL_ -- so this will effectively capture what is written to the log as the result of the %PUT _ALL_ and then the log will return to normal after the second PROC PRINTTO.

You could, of course, put any number of specific %PUT statements in between the PRINTTO steps.

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1160 views
  • 0 likes
  • 4 in conversation