Is there a way to redirect put statements within the data step to the result rather than the log?
Using PUT statement uses as default the FILE LOG output;
You can define any other output including FILE PRINT to have the output on result window.
data _null_;
file print; put 'Output to result window';
file log; put 'Return to default';
run;
Show us what your trying to do. What are your writing to log matters.
I'm using SAS 9.4 under AIX 7 with bash. I'm trying to redirect the output from put statements into a file. I want the following command to output "hello, foobar" to stdout.
sas -stdio <(echo 'data _null_; put "hello, foobar"; run;') 2>/dev/null
It seems the only way to accomplish this is to explicitly use the file statement like this:
sas -stdio <(echo 'data _null_; file stdout; put "hello, foobar"; run;') 2>/dev/null
Using PUT statement uses as default the FILE LOG output;
You can define any other output including FILE PRINT to have the output on result window.
data _null_;
file print; put 'Output to result window';
file log; put 'Return to default';
run;
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.