Just did some searching and reading on SAS log file directing. And, phew!, seems to be a crazy topic, all across the board.
Simply put, I'd like to process several datasets, one at a time:
aaa.sas7bdat
bbb.sas7bdat
ccc.sas7bdat
Each dataset resides within its own folder:
c:\1\aaa\aaa.sas7bdat
c:\1\bbb\bbb.sas7bdat
c:\1\ccc\ccc.sas7bdat
(I'd like to process all the datasets using a macro. But will inquire about how to do that tomorrow.)
For now, when processing aaa.sas7bdat, I would like to create a log -- log_aaa.txt -- within c:\1\aaa\.
Following completion of that process, I'd like to move on to bbb.sas7bdat. And during the process create a new log file -- log_bbb.txt. That file should reside in the respective c:\1\bbb\.
On and on....
You get the picture?
Any sage advice on how best to do this will be greatly appreciated.
Thanks!
Nicholas Kormanik
proc printto log="c:\1\aaa\log_aaa.txt"; /* Re-direct log to the file named */
run;
/* Any code for data set aaa goes here */
proc printto; /* Turns off sending log to file named above */
run;
proc printto log="c:\1\aaa\log_aaa.txt"; /* Re-direct log to the file named */
run;
/* Any code for data set aaa goes here */
proc printto; /* Turns off sending log to file named above */
run;
This should get you an idea:
%macro process(loc=);
proc printto log="c:\1\&loc.\log_&loc..txt";
run;
libname process "c:\1\&loc.";
data temp;
set process.&aaa.;
/* further processing */
run;
proc printto log=log; /* reroute to default */
run;
%mend;
Then call that repeatedly:
%process(loc=aaa);
%process(loc=bbb);
%process(loc=ccc);
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.