Hello,
I have inherited some code that uses a put statement within data _null_ step to write out to csv. Is there any way to prevent the put statement from writing out values to the log? Thanks
Log
83129 data _null_;
83130 set sashelp.class;
83131 put name;
83132 run;
Alfred
Alice
Barbara
Carol
Henry
James
Jane
Janet
Jeffrey
John
Joyce
Judy
Louise
Mary
Philip
Robert
Ronald
Thomas
William
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
The usual way to write values to a file instead of the log is to redirect them yourself using the FILE statement:
data _null_;
set sashelp.class;
file "path to the file where you want the PUT messages written";
put name;
run;
@kimdukes77 wrote:Hello,
I have inherited some code that uses a put statement within data _null_ step to write out to csv. Is there any way to prevent the put statement from writing out values to the log? Thanks
Log
83129 data _null_;
83130 set sashelp.class;
83131 put name;
83132 run;Alfred
Alice
Barbara
Carol
Henry
James
Jane
Janet
Jeffrey
John
Joyce
Judy
Louise
Mary
Philip
Robert
Ronald
Thomas
William
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
Assuming you're sure your code runs without errors, you can try adding:
options nonotes;
to just before your data _null_ step
and then add
options notes;
to just after your data _null_ step
You might be able to just use options nosource / options source instead; I'm not sure which one will suppress the PUT info being copied to the log.
Thank you for the response. I probably (definitely) should have mentioned in my original post that I have tried nonotes, nosource and nosource2 and none of those options work. Values are still written out to the log. I suspect I will need to write out log to a txt file (not the preferred option) or update the code to use proc report or print instead of _null_ and put.
If you don't want data in the log, remove (or comment) the put statement. Right now, the put statement explicitly forces SAS to write to the log.
The usual way to write values to a file instead of the log is to redirect them yourself using the FILE statement:
data _null_;
set sashelp.class;
file "path to the file where you want the PUT messages written";
put name;
run;
Amazing thank you! A simple and elegant solution to what I foolishly assumed was a complex problem!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.