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

I'm trying to find the SAS system option to capture the status of program in a variable. I tried with &SYSERR and &SYSRC but it is not producing the desired result. In the below example I would except &SYSERR to return code as 4 (SYSERR code for warning message) instead of 0 (which denotes successful execution without any warning message). Same is the case if I replace &SYSERR with &SYSRC.

 

I could see that &SYSERR is generating the value 0 if I place &SYSERR at the end of the data step in the below program.

 

2097       %PUT &SYSERR;
0
2098       /*derive operationl metadata*/
2099       data metadata;
2100       set vars;
2101       /*Solution Component Name derivation*/
2102       if find("&etls_jobName","_INPUT_",'_') > 0
2103       then SOLN_CMPNT_NM= "DATA IMPORT";
2104       else if find("&etls_jobName","_EXPORT_") > 0
2105       then SOLN_CMPNT_NM = "DATA EXPORT" ;
2106       else if find("&etls_jobName","_LOA_") > 0
2107       then SOLN_CMPNT_NM = "DATA LOADER" ;
2108       else if find("&etls_jobName","_TRA_") > 0
2109       then SOLN_CMPNT_NM = "DATA TRANSER" ;
2110       else SOLN_CMPNT_NM = "OTHER" ;
2111       /*Job return code*/
2112       /*%PUT &SYSRC.;*/
2113       run;

WARNING: In a call to the FIND function or routine, the modifier "_" not valid.
NOTE: There were 1 observations read from the data set WORK.VARS.
NOTE: The data set WORK.METADATA has 1 observations and 10 variables
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

This seems to be a bug in the find() function, as a WARNING should cause a change in syscc:

73         %let syscc=0;
 74         
 75         data test;
 76         keep x1;
 77         run;
 
 WARNING: The variable x1 in the DROP, KEEP, or RENAME list has never been referenced.
 NOTE: The data set WORK.TEST has 1 observations and 0 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 
 78         
 79         %put syscc=&syscc;
 syscc=4
 80         
 81         %let syscc=0;
 82         
 83         data test;
 84         x1 = 'X';
 85         x2 = 'Y';
 86         x3 = find(x1,x2,'_');
 87         run;
 
 WARNING: In a call to the FIND function or routine, the modifier "_" not valid.
 NOTE: The data set WORK.TEST has 1 observations and 3 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 88         
 89         %put syscc=&syscc;
 syscc=0

Bring this to the attention of SAS technical support.

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

This seems to be a bug in the find() function, as a WARNING should cause a change in syscc:

73         %let syscc=0;
 74         
 75         data test;
 76         keep x1;
 77         run;
 
 WARNING: The variable x1 in the DROP, KEEP, or RENAME list has never been referenced.
 NOTE: The data set WORK.TEST has 1 observations and 0 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 
 78         
 79         %put syscc=&syscc;
 syscc=4
 80         
 81         %let syscc=0;
 82         
 83         data test;
 84         x1 = 'X';
 85         x2 = 'Y';
 86         x3 = find(x1,x2,'_');
 87         run;
 
 WARNING: In a call to the FIND function or routine, the modifier "_" not valid.
 NOTE: The data set WORK.TEST has 1 observations and 3 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 88         
 89         %put syscc=&syscc;
 syscc=0

Bring this to the attention of SAS technical support.

Quentin
Super User

Ugh, if every function is responsible for deciding whether or not to set SYSCC when it throws a warning/error, it shouldn't be a surprise that error handling in SAS is so awkward.  (And I say that as a fan of SAS. : )  

 

As a work around, you could check &syswarningtext , which unfortunately is read only, so you can't reset it.

 

Or resort to log scanning.  I definitely see the benefit of return codes, but tend to trust the log messages more than return codes. Sometimes I'll do my own log scan, and use that to generate my own return code.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 965 views
  • 2 likes
  • 3 in conversation