BookmarkSubscribeRSS Feed
Schwa
Fluorite | Level 6

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?

11 REPLIES 11
PaigeMiller
Diamond | Level 26

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

--
Paige Miller
Schwa
Fluorite | Level 6

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

SASKiwi
PROC Star

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.

Reeza
Super User
If you cannot share your real code or log, then make up fake code that is in each of program1/program2, run that and post it. Basically, create a reproducible example that's very basic. Each program can run a proc means on sashelp.class or something that depends on each other. If it works in the test case then you keep adding complexity until it breaks similar to your current code and that'll tell you how to debug it. It also means you can post your log and code while debugging because there's nothing confidential. This is a fairly efficient debugging technique.
SASKiwi
PROC Star

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. 

ballardw
Super User

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

Reeza
Super User

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. 

Tom
Super User Tom
Super User

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.

data_null__
Jade | Level 19

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.

 

Reeza
Super User

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.

tomrvincent
Rhodochrosite | Level 12
There's probably a macro that's redefined somewhere.

I'd do this:
%macro prog1;
%include "/path/program1.sas";
%mend;
%macro prog2;
%include "/path/program2.sas";
%mend;
%macro prog3;
%include "/path/program3.sas";
%mend;
%macro prog4;
%include "/path/program4.sas";
%mend;
%macro prog5;
%include "/path/program5.sas";
%mend;
%prog1;
%prog2;
%prog3;
%prog4;
%prog5;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 2887 views
  • 4 likes
  • 8 in conversation