Standing up a flag here, I'm planning to keep a series of notes to minute my questions met in sas learning. Practice is the best teacher, practice makes perfect!
When we run programs in SAS, we usually see the log to check if the programs run successfully. The most common approach is to check it in the SAS directly. However in the clinical trial, it may be beneficial to check the external log files generated from your programs so that we can check all log files at once. For example, see if there are some errors or warnings inside without visual inspection by eyes. This post demonstrates how to use SAS code to output logs to external files in SAS.
So far I have known that there are two approaches to reach our purpose.
The first way is to use
proc printto like:
proc printto log="./log1.txt" new; run; data class; set sashelp.cars; where origin="Asia"; run; /*revert log to the log window*/ proc printto; run;
Put the file path in the
Log=option and then that output file will contain the log. The
new option is defined so that SAS replaces the previous contents of the log file. Otherwise sas appends the new log to the current file.
It looks like you just need to put your running codes between the two
proc printto procedures, which is very easy and straightforward.
The second way is to use
dm replace , and this way is also very easy and I like it indeed.
data class; set sashelp.cars; where origin="Asia"; run; dm 'log; log; file "./log1.txt" replace ;'; run;
Put this standard code at the end of your program just the
file option needs to be specified.
But someone said the
dm replace way is limited by the rows of logs in SAS.
So then which approach do you prefer?
Please indicate the source: http://www.bioinfo-scrounger.com