Dear expert,
Having a several sas programs ordred as Follow :
Folder_1/1_Test.sas
/2_PGM.sas
Folder_2/1_PGM.sas
/2_PM.sas
I want to
1) Create a main program for all sas program like this( the program order is important):
%include /Dir/Dir1/ Folder_1/1_Test.sas
2) create a log file for every program
3) analyze the files log in order to find: ERROR, Warning, _ORROR_
Thank you in advance
Are you running SAS on Unix or Windows? (or IBM mainframe?)
Are you trying to run all of the programs in a single SAS session?
Or do you want to run them completely independently of each other?
The last is the best as then you don't have to play games with re-directing the log or worry about mistakes in one program putting SAS into strange state or programs only working because of side effects level over from the previous program.
So you probably just want to create an operating system command file to run the commands.
So on Unix it would look something like:
cd /..../Folder_1 sas 1_Test.sas grep ^ERROR.*: 1_Test.log sas 2_PGM.sas grep ^ERROR.*: 2_PGM.log cd /.../Folder_2 ...
Thank you very much.
It will run for all Operating System (not only unix) and in one sas session.
I want some thing automatic, linkg to all sas programs, keeping the programs order, create a log files and analysis the error and warning by program
@LineMoon wrote:
Thank you very much.
It will run for all Operating System (not only unix) and in one sas session.
I want some thing automatic, linkg to all sas programs, keeping the programs order, create a log files and analysis the error and warning by program
As I said that will introduce a lot more complications. Once you have run one of the programs the others can never be sure what state SAS is in when they start. So your system will be more fragile and require more complications.
If you just want to run all of the programs in one SAS job you could do something like:
filename dir1 '/..../Folder_1';
%include dir1('*.sas') / source2;
If you are saying you want to write the part of the SAS log generated by each file to separate locations that will require a lot more work. You either have to have a dataset with the list of program files, or use code to generate the list by reading the directory.
So say you created a dataset name FILES with a variable named PROGRAM you might use that to generate code like this:
filename code temp;
data _null_;
set files ;
file code;
log=program;
log=tranwrd(log,'.sas','.log');
put 'proc printto log=' log :$quote. ';run;'
/ '%include ' program :$quote. ';'
/ 'proc printto log=log; run;'
;
run;
%include code / source2;
So your company/institution runs multiple SAS servers on multiple different operating systems (also implying multiple SAS licenses)? This is quite unique.
@LineMoon wrote:
Thank you very much.
It will run for all Operating System (not only unix) and in one sas session.
I want some thing automatic, linkg to all sas programs, keeping the programs order, create a log files and analysis the error and warning by program
This is called scheduling. Your company/institution will already have such in place; consult the admins how to integrate your SAS programs there.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.