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 🙂
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.