I work in an environment where we are supposed to run very long programs in an batch session instead of an interactive one. I have several programs (.sas files) that regularly need to be run in sequence, but it must be done specifically within another .sas file (that I can send to the computation server). It was my understanding that if I were to run a file who's entire body was:
%include "/path/program1.sas";
%include "/path/program2.sas";
%include "/path/program3.sas";
%include "/path/program4.sas";
%include "/path/program5.sas";
that this would run program1.sas then run program2.sas then run program3.sas etc. My problem is this: when I run the programs "by hand", i.e. run program1.sas then wait for it to be finished before running program2.sas etc, I do't get any errors. However, when I run the above program I get all sorts of errors.
What is my misunderstanding here?
@Schwa wrote:
I work in an environment where we are supposed to run very long programs in an batch session instead of an interactive one. I have several programs (.sas files) that regularly need to be run in sequence, but it must be done specifically within another .sas file (that I can send to the computation server). It was my understanding that if I were to run a file who's entire body was:
%include "/path/program1.sas";
%include "/path/program2.sas";
%include "/path/program3.sas";
%include "/path/program4.sas";
%include "/path/program5.sas";
that this would run program1.sas then run program2.sas then run program3.sas etc. My problem is this: when I run the programs "by hand", i.e. run program1.sas then wait for it to be finished before running program2.sas etc, I do't get any errors. However, when I run the above program I get all sorts of errors.
What is my misunderstanding here?
What errors do you get? Please show us the ENTIRE log (not just the ERROR messages), preserving the formatting of the log, by clicking on the {i} icon and pasting the log into the window that appears. Do not skip this step.
Unfortunately I cannot, I work with sensitive information that must undergo a disclosure process. But the (first) errors occurring seem to be happening at the beginning of one of the programs (the last time I ran it it was right at the beginning of the third program, in a data step that calls a set that would have been created at the end of the second program, which ran with no errors.) Could this be something specifically peculiar to the environment I work in? (I work in a Census Bureau RDC.)
SAS errors are generic and don't disclose anything specific to your organisation. You should be able to post the errors you are getting, You can blank out table and column names if necessary.
A possible cause of your errors is your batch isn't set up the same as your interactive one. Your SAS log will contain evidence of this.
@SASKiwi wrote:
A possible cause of your errors is your batch isn't set up the same as your interactive one. Your SAS log will contain evidence of this.
Create a short program that contains this code:
Proc Options;
run;
Run it in a BATCH session and save the output. log
Run the same in an interactive session.
Compare the two outputs. You will likely find some differences and some may be
If you specify a different autoexec for your batch sessions than your interactive session used than compare those as well.
If you do not know what the options that do not match, or appear, in both outputs mean then it is time use the documentation.
It may be that you need to specify a modified config or autoexec file for your batch mode.
1. Are you using RSUBMIT?
2. Are you using SAS/CONNECT?
3. What is your CONNECTWAIT option?
proc options option=connectwait;
run;
If you're in Statistics Canada Research Centre there are many users there who can assist you on making sure your program run correctly.
You need to be more specific about the errors. Concentrate on the first ERROR since once you have had a single error the rest of the program might not work as a side effect of the first error.
You can use SYSTASK COMMAND and simulate running each program one at a time in Batch mode. There are options to WAITFOR the current task before going to the next. Look at the documentation and then come back ask if you need help.
Try adding LRECL to your %include. IF you have long lines of code they can get truncated.
%include "...." / lrecl=30000 SOURCE2;
This was a common issue in certain situations.
EDIT: add SOURCE2 option so you can see the full log as well.
Default LRECL is often 256 characters.
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.