Help using Base SAS procedures

SAS Batch does not run correctly, but individual programs do.

Accepted Solution Solved
Reply
Contributor
Posts: 45
Accepted Solution

SAS Batch does not run correctly, but individual programs do.

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.


Accepted Solutions
Solution
‎11-18-2015 01:44 PM
Community Manager
Posts: 2,769

Re: SAS Batch does not run correctly, but individual programs do.

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

 

View solution in original post


All Replies
Trusted Advisor
Posts: 1,631

Re: SAS Batch does not run correctly, but individual programs do.

Do you get an error message?

 

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

Contributor
Posts: 45

Re: SAS Batch does not run correctly, but individual programs do.

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;

 

 

Contributor
Posts: 45

Re: SAS Batch does not run correctly, but individual programs do.

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;

Community Manager
Posts: 2,769

Re: SAS Batch does not run correctly, but individual programs do.

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

Contributor
Posts: 45

Re: SAS Batch does not run correctly, but individual programs do.

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.

 

 

Super User
Posts: 10,543

Re: SAS Batch does not run correctly, but individual programs do.

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.

 

Contributor
Posts: 45

Re: SAS Batch does not run correctly, but individual programs do.

Hello,

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


Community Manager
Posts: 2,769

Re: SAS Batch does not run correctly, but individual programs do.

[ Edited ]

@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 Smiley Happy

Contributor
Posts: 45

Re: SAS Batch does not run correctly, but individual programs do.

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

Solution
‎11-18-2015 01:44 PM
Community Manager
Posts: 2,769

Re: SAS Batch does not run correctly, but individual programs do.

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

 

Contributor
Posts: 45

Re: SAS Batch does not run correctly, but individual programs do.

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 11 replies
  • 938 views
  • 1 like
  • 4 in conversation