BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

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

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

@TobiasGrossmann

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.

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

"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.

Patrick
Opal | Level 21

@TobiasGrossmann

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.

TobiasGrossmann
Calcite | Level 5

thanks a lot 🙂

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 425 views
  • 1 like
  • 3 in conversation