BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Asbon
Obsidian | Level 7

data _null_;

RSUBMIT wait=no log=mylog1 cmacvar=auths new;

%include "/sasdata/cro_rte/user_libs/crm_prod/aasbon/systask/rsubmit/test/tes1.sas";

%SYSRPUT auths1=&syserr.;

endrsubmit;

waitfor _all_;
signoff _all_;

%put &auths1.;

data _null_;

if &auths1. >4  then do;
putlog 'ERROR occured during the execution of tes1.sas';
abort cancel;
end;

run;

 

 

In above code, i;m trying capture &syserr value through %sysrput so that i can debug and stop if error occurs.

but, values through %SYSRPUT auths1=&syserr.; is different where if i give %put &syserr in tes1.sas code is different.

 

eg:-%put &syserr in tes1.sas code is 1024

%put &auths1. is 3 
can some please helpin this, 
Help is appreciable.

 

Thanks,

kenneth.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Where and how do you determine the &SYSERR value in test1.sas?

 

As an indicator of successful code execution, &SYSCC is much better, as it is not constantly changed by DATA and PROC steps, but keeps the max value.

 

From the documentation of SYSERR:

SYSERR automatic macro variable is reset at each step boundary.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

Where and how do you determine the &SYSERR value in test1.sas?

 

As an indicator of successful code execution, &SYSCC is much better, as it is not constantly changed by DATA and PROC steps, but keeps the max value.

 

From the documentation of SYSERR:

SYSERR automatic macro variable is reset at each step boundary.

SASJedi
SAS Super FREQ

I believe the placement of your RSUBMIT statements is incorrect. Half of your DATA _NULL_ step appears to be in the local session, and half in the remote. 

I used these text files for testing:

 

/* Create a "good" and "bad" test code file */
data _null_;
	file "good.sas";
	put "set sashelp.class;";
	file "bad.sas";
	put "set bad_dsn;";
run;

I ran this RSUBMIT code to test the good file:

 

 

/* Test RSUBMIT code with GOOD file */
signon session1 sascmd="!sascmd -nosyntaxcheck -noterminal";
	rsubmit session1 wait=no;
	%let pgFile=good.sas;
	data _null_;
		%include "&pgFile";
	run;
    %SYSRPUT auths1=&syserr.;
%sysrput pgFile=&pgfile;
endrsubmit; waitfor _all_; signoff _all_; %put NOTE: &=auths1; data _null_; if &auths1. >4 then do; putlog "ERROR: An occured during the execution of &pgFile"; abort cancel; end; else putlog "NOTE: &pgFile ran without error."; run;

With this result:

 

 

NOTE: Remote signon to SESSION1 complete.
203     rsubmit session1 wait=no;
NOTE: Background remote submit to SESSION1 in progress.
204  waitfor _all_;
205  signoff _all_;
NOTE: Remote submit to SESSION1 commencing.
1       %let pgFile=good.sas;
2       data _null_;
3          %include "&pgFile";
5       run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


6       %SYSRPUT auths1=&syserr.;
7       %sysrput pgFile=&pgfile;
NOTE: Remote submit to SESSION1 complete.
NOTE: Remote signoff from SESSION1 commencing.
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
      real time           0.95 seconds
      cpu time            0.46 seconds

NOTE: Remote signoff from SESSION1 complete.
206
207  %put NOTE: &=auths1;
NOTE: AUTHS1=0
208  data _null_;
209     if &auths1. >4  then do;
210        putlog "ERROR: An occured during the execution of &pgFile";
211        abort cancel;
212     end;
213     else
214        putlog "NOTE: &pgFile ran without error.";
215  run;

NOTE: good.sas ran without error.

Then I ran this code to test the bad file:

 

 

/* Test RSUBMIT code with BAD file */
signon session1 sascmd="!sascmd -nosyntaxcheck -noterminal";
	rsubmit session1 wait=no;
	%let pgFile=bad.sas;
	data _null_;
		%include "&pgFile";
	run;
    %SYSRPUT auths1=&syserr.;
%sysrput pgFile=&pgfile;
endrsubmit; waitfor _all_; signoff _all_; %put NOTE: &=auths1; data _null_; if &auths1. >4 then do; putlog "ERROR: An occured during the execution of &pgFile"; abort cancel; end; else putlog "NOTE: &pgFile ran without error."; run;

And got the expected result:

 

 

NOTE: Remote signon to SESSION1 complete.
219     rsubmit session1 wait=no;
NOTE: Background remote submit to SESSION1 in progress.
220  waitfor _all_;
221  signoff _all_;
NOTE: Remote submit to SESSION1 commencing.
1       %let pgFile=bad.sas;
2       data _null_;
3          %include "&pgFile";
ERROR: File WORK.BAD_DSN.DATA does not exist.
5       run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


6       %SYSRPUT auths1=&syserr.;
7       %sysrput pgFile=&pgfile;
NOTE: Remote submit to SESSION1 complete.
NOTE: Remote signoff from SESSION1 commencing.
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
      real time           0.89 seconds
      cpu time            0.51 seconds

NOTE: Remote signoff from SESSION1 complete.
222
223  %put NOTE: &=auths1;
NOTE: AUTHS1=1012
224  data _null_;
225     if &auths1. >4  then do;
226        putlog "ERROR: An occured during the execution of &pgFile";
227        abort cancel;
228     end;
229     else
230        putlog "NOTE: &pgFile ran without error.";
231  run;

ERROR: An occured during the execution of bad.sas
ERROR: Execution terminated by an ABORT CANCEL statement at line 227 column 7.
_ERROR_=1 _N_=1

 

 

Check out my Jedi SAS Tricks for SAS Users
s_lassen
Meteorite | Level 14

As @Kurt_Bremser remarked, the value of &SYSERR is the latest value of the error code. Much better to use SYSCC, which contains the maximum error code encountered so far, and which can be reset by the program:

RSUBMIT wait=no log=mylog1 cmacvar=auths new;
%let SYSCC=0; /* So far, so good */
%include "/sasdata/cro_rte/user_libs/crm_prod/aasbon/systask/rsubmit/test/tes1.sas";
%SYSRPUT auths1=&SYSCC.;
ENDRSUBMIT;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 387 views
  • 7 likes
  • 4 in conversation