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

Hello,

I have a SAS batch file in which I am trying to run multiple SAS programs (9.2) through a task scheduler.  The BAT file does run, however the SAS programs are not running correctly.  Some of the programs only provide output for 5 of 50 charts, but if I run the program individually it runs perfect.  I am using ODS output to multiple file locations.

 

The following is the current SAS BAT file:

 

start/w C:\"Program Files"\SAS\SASFoundation\9.2\sas.exe -log "G:\QA\QA Metrics\Data Trending\Logs\Product1.log" -sysin "G:\QA\QA Metrics\Data Trending\Product1.sas"
start/w C:\"Program Files"\SAS\SASFoundation\9.2\sas.exe -log "G:\QA\QA Metrics\Data Trending\Logs\Product2.log" -sysin "G:\QA\QA Metrics\Data Trending\Product2.sas"
start/w C:\"Program Files"\SAS\SASFoundation\9.2\sas.exe -log "G:\QA\QA Metrics\Data Trending\Logs\Product3.log" -sysin "G:\QA\QA Metrics\Data Trending\Product3.sas"
start/w C:\"Program Files"\SAS\SASFoundation\9.2\sas.exe -log "G:\QA\QA Metrics\Data Trending\Logs\Product4.log" -sysin "G:\QA\QA Metrics\Data Trending\Product4.sas"
start/w C:\"Program Files"\SAS\SASFoundation\9.2\sas.exe -log "G:\QA\QA Metrics\Data Trending\Logs\Product5.log" -sysin "G:\QA\QA Metrics\Data Trending\Product5.sas"
start/w C:\"Program Files"\SAS\SASFoundation\9.2\sas.exe -log "G:\QA\QA Metrics\Data Trending\Logs\Product6.log" -sysin "G:\QA\QA Metrics\Data Trending\Product6.sas"
start/w C:\"Program Files"\SAS\SASFoundation\9.2\sas.exe -log "G:\QA\QA Metrics\Data Trending\Logs\Product7.log" -sysin "G:\QA\QA Metrics\Data Trending\Product7.sas"
start/w C:\"Program Files"\SAS\SASFoundation\9.2\sas.exe -log "G:\QA\QA Metrics\Data Trending\Logs\ErrorSearch.log" -sysin "G:\QA\QA Metrics\Data Trending\ErrorSearch.sas"

 

Eventually this will grow to around 100 SAS programs, that is if it will run correctly.

 

Also, I took the time to make a giant SAS program with all of the above programs in one program.  When I ran that program, it too ran properly.  However, doing this makes it a little challenging to make changes to individual codes as the program will be approximately 150,000 lines long or more.  The BAT file does run individual files fine.  The first program in the BAT file with all SAS programs appears to run correctly too, but after that it goes downhill.

 

Any advice/help would be greatly appreciated,
Thank you,

Jeff S. O.

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

The specific error in the second log, where things begin to go wrong, is this:

 

ERROR: BY variables are not properly sorted on data set WORK.PHASES.

Lot_Count=4264 Microtablet_Dissolution_S1X=91.166666667 Microtablet_Dissolution_S1R=5 Microtablet_Dissolution_S1N=6

_PHASE_=Last 100 Lots with Results _Lot_=170187 FIRST.Lot_Count=1 LAST.Lot_Count=1 _VAR_=  _ERROR_=1 _N_=99

NOTE: The SAS System stopped processing this step because of errors.

 

I can't see the code, but I guess you have a DATA step with a BY statement that tries to do FIRST-dot and LAST-dot processing, and that requires that your data be sorted by those variables (Lot_Count, I guess).  Maybe in some cases that happens by luck, but in this run sequence the records are out of order.

 

Chris

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

11 REPLIES 11
PaigeMiller
Diamond | Level 26

Do you get an error message?

 

Do you set limits on how long the batch file can run?

--
Paige Miller
Jolly
Calcite | Level 5

I get several errors when running the BAT file, errors that do not occur when running each program individually.  I get syntax errors and errors for macros calling variable they do not exist.  The following is one of 27 pages from my error search document:

ERROR 76-322: Syntax error, statement will be ignored.

ERROR 22-322: Syntax error, expecting one of the following: a name, ;.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: The SAS System stopped processing this step because of errors.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant,

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant,

NOTE: The SAS System stopped processing this step because of errors.

ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, a missing value, (.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR 76-322: Syntax error, statement will be ignored.

ERROR 22-322: Syntax error, expecting one of the following: a name, ;.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: The SAS System stopped processing this step because of errors.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant,

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant,

NOTE: The SAS System stopped processing this step because of errors.

ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, a missing value, (.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR 76-322: Syntax error, statement will be ignored.

ERROR 22-322: Syntax error, expecting one of the following: a name, ;.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: The SAS System stopped processing this step because of errors.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant,

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant,

NOTE: The SAS System stopped processing this step because of errors.

ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, a missing value, (.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR 76-322: Syntax error, statement will be ignored.

ERROR 22-322: Syntax error, expecting one of the following: a name, ;.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: The SAS System stopped processing this step because of errors.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant,

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant,

NOTE: The SAS System stopped processing this step because of errors.

ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, a missing value, (.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR 76-322: Syntax error, statement will be ignored.

ERROR 22-322: Syntax error, expecting one of the following: a name, ;.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: The SAS System stopped processing this step because of errors.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant,

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant,

 

 

Also,  I have the following code at the beginning of each program to close out any open files and to delete any data sets:

 

proc datasets library=work kill;
run;
quit;

ODS _ALL_ CLOSE;

 

 

Jolly
Calcite | Level 5

Hello,


I do get several errors that I do not get when I run the programs individually.  I get syntax errors and errors for macro calls of variables in which SAS says does not exist.  Attached is the error document provided from the last SAS program ran in the BAT file.

Also, at the start of each document I use the following code to prevent anything from carrying over:

 

proc datasets library=work kill;
run;
quit;

ODS _ALL_ CLOSE;

ChrisHemedinger
Community Manager

Since each of these programs runs in a new SAS session, the environment is reset as each program is launched.  So anything that later programs might depend on needs to be established:

 

- SAS LIBNAME definitions

- system options in the OPTIONS statement

- intermediate data that might be in the WORK library

- SAS Format definitions from PROC FORMAT

 

When everything seems to work okay in a single session, but begins to break down when you chunk it up, it's time to look at the above "transient" items that your later programs might depend on (even if that's not what you intended).

 

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Jolly
Calcite | Level 5

Hello Chris,

Thank you for looking into this for me.  Each program is independent of the others.  I had figured the kill and close statments at the beginning of each program would take care of issues from anything from the prior program being carried over.

 

 

ballardw
Super User

You may want to investigate use of %include. It is a way for one SAS program file to reference many others.

You would then have the batch program run the SAS controlling program that would include lines similar to:

 

%include "G:\QA\QA Metrics\Data Trending\Product1.sas";

%include "G:\QA\QA Metrics\Data Trending\Product2.sas";

%include "G:\QA\QA Metrics\Data Trending\Product3.sas";

 

This approach would allow you to use some logic between %include to test existence or results if needed. Also if you wanted to exclude one of the %included programs all that is needed is to put an * in front of the line to comment it out of execution.

 

Jolly
Calcite | Level 5

Hello,

I did try this, but it appeared to have made things even worse.


ChrisHemedinger
Community Manager

@Jolly, for the community to really help, I think you'll have to provide some example output logs that show where things go wrong.  It might not be enough to help, but the experts here might recognize certain errors as symptoms of something common.

 

Update: nevermind, looks like you just did 🙂

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Jolly
Calcite | Level 5

Hey Chris,

Here is the log for the program that is submitted after the first few in the BAT file.  Product1 is the very first program to run and product2 is submitted after the first 3 programs.

Thank you

ChrisHemedinger
Community Manager

The specific error in the second log, where things begin to go wrong, is this:

 

ERROR: BY variables are not properly sorted on data set WORK.PHASES.

Lot_Count=4264 Microtablet_Dissolution_S1X=91.166666667 Microtablet_Dissolution_S1R=5 Microtablet_Dissolution_S1N=6

_PHASE_=Last 100 Lots with Results _Lot_=170187 FIRST.Lot_Count=1 LAST.Lot_Count=1 _VAR_=  _ERROR_=1 _N_=99

NOTE: The SAS System stopped processing this step because of errors.

 

I can't see the code, but I guess you have a DATA step with a BY statement that tries to do FIRST-dot and LAST-dot processing, and that requires that your data be sorted by those variables (Lot_Count, I guess).  Maybe in some cases that happens by luck, but in this run sequence the records are out of order.

 

Chris

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Jolly
Calcite | Level 5

After adding an additional proc sort statment, it appears to run correctly.  I have no clue why this issue was not appearing when the individual programs were submitted and providing everything from the code, but it was a small simple fix.  

Thank you very much.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 11 replies
  • 4924 views
  • 1 like
  • 4 in conversation