Hi SAS Experts,
I try to run mutliple SAS programs in a Batch after each other and Re-Use all the results from the previous executed programs.
Why: I start with an EGP Project, nicely ordering the code in diffrent programs, and then export everything to *.sas files to get a batch ready enviroment.
To run the diffrent programs I created a SAS macro, in the hope it will keep the Session, unfortiantly, it doestn seems to work:
run.sas :
%let basepath = /srv/sas/projects/cirun/fwd;
%let projectname = /myprojectfiles/;
run;
%include "&basepath.&projectname.build/00a_init.sas";
run;
%include "&basepath.&projectname.build/01a_load_akq.sas";
run;
...and ongoing...
Any Ideas?
Regards,
Tobi
An %include statement allows you to include SAS code kept in another file BUT the code gets run as if all this code would directly "live" in the place where you've got the %include statement.
For this reason organizing code in multiple files and then bringing it together with %include statements, runs the all the code as one big single programs and for this reason you should have all the tables accessible within the same session.
It doesn't matter if you run the master program (with the %includes in it) in batch or in an interactive session. It's still: All the code is together so everything should be available to all the bits as long as the session is active.
"Batch after each other and Re-Use all the results from the previous executed programs." - If you have several programs that all use the same output, then link them in one overall file, batch submit the overall file, and they can then include all the sub programs - i.e. one session lots of programs being run. Not much point in starting a new session for each program, as you then need to start up and close SAS each, and store outputs to a physical location for the next part of the process. So unless there is a really good reason, 1 session, which runs all your code would be better.
An %include statement allows you to include SAS code kept in another file BUT the code gets run as if all this code would directly "live" in the place where you've got the %include statement.
For this reason organizing code in multiple files and then bringing it together with %include statements, runs the all the code as one big single programs and for this reason you should have all the tables accessible within the same session.
It doesn't matter if you run the master program (with the %includes in it) in batch or in an interactive session. It's still: All the code is together so everything should be available to all the bits as long as the session is active.
thanks a lot 🙂
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.