BookmarkSubscribeRSS Feed
FatCaptain
Fluorite | Level 6
Hi,

I'm trying to generate a variable in SAS which shows whether the code has run without any errors.

The main body of the code is run on the server using an rsubmit command. The error variable needs to be available locally on my pc.

The code is very simple as it just backs up some SAS datasets e.g.



rsubmit;

data dataset_backup ;
set dataset ;
run ;

data dataset2_backup ;
set dataset2 ;
run ;

endrsubmit;



Do I need to include a error check in each and every data step or is there a single variable which gets set if any error anywhere is found?

I've tried playing around with &syserr and &_efierr_ to obtain an error flag and %sysrput to return it to the local pc from the server but can't get anything to work.

Any help with this would be appreciated.

Thanks,

Fat Captain.
3 REPLIES 3
Ksharp
Super User
As far as i remember , there are two auto macro variables ( &syserrortext &syswarningtxt )
which include the last error text and the last warning txt.




Ksharp
Peter_C
Rhodochrosite | Level 12
have you tried &SYSCC
data_null__
Jade | Level 19
Using Mr. C's suggestion to use CC you might do something like this.

[pre]
286 proc transpose data=sashelp.class;
287 var sex;
288 run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.DATA14 has 1 observations and 20 variables.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
real time 0.48 seconds
cpu time 0.00 seconds


289 %sysfunc(ifC(&syscc,%nrstr(%put NOTE: BAD CC ENDSAS?;),%nrstr(%put NOTE: All good keep going)));
NOTE: All good keep going
290
291 proc transpose data=sashelp.class;
292 var sexx;
ERROR: Variable SEXX not found.
293 run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.DATA15 may be incomplete. When this step was stopped there were 0 observations and 0 variables.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
real time 0.54 seconds
cpu time 0.00 seconds

294 %sysfunc(ifC(&syscc,%nrstr(%put NOTE: BAD CC ENDSAS?;),%nrstr(%put NOTE: All good keep going)));
NOTE: BAD CC ENDSAS?

[/pre]



For batch jobs a simple ENDSAS statement should be good. For a DMS session you want to keep alive you will need something else, but I'm not sure what.

A little searching at support.sas.com I find DM command WATTENTION. http://support.sas.com/kb/38/749.html

[pre]
%sysfunc(ifC(&syscc,%nrstr(dm 'WATTENTION';),%nrstr(%put NOTE: All good keep going)));
[/pre]

WATTENTION


Message was edited by: data _null_;

Well WATTENTION does bring up the dialogue but when you select Cancel Submitted Statements it does not cancel them.

http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0709C&L=sas-l&P=R17140 Message was edited by: data _null_;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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