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

I am running a program which is scheduled through the SAS Management Console and usually I get email notifications if the program ran successfully (Done Status) or did it Exit (meaning SAS says it had some issues). These email triggers are auto generated through the Management Console. 

 

Now, one of my programs is generating an Exit Status because of below 2 lines. But these are not actually errors, but just warnings and the program is fine. I am trying to figure out if there is a way for me to have SAS suppress/ ignore certain type of these warnings, so that I can have Management console generate a Success Status notification and not Exit.  

 

NOTE: Invalid third argument to function SUBSTR at line 554 column 12.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed. 

 

--Tb

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

I would say that is an error.  It's just unfortunate that SAS writes a NOTE: to the log rather than an ERROR: message.  This is one of many notes that are really errors.

 

That said, first question would be what value is causing the problem fro SUBSTR()?  Note that there is a SUBSTRN() function which will accept some arguments that are invalid arguments for SUBSTR().  For example, if the third argument is longer than the length of the first argument, SUBSTRN() will truncate it rather than throw an error.  Depending on the cause of your problem, SUBSTRN() might let you handle more cases without generating an error.

 

data want ;
  set sashelp.class ;
  x=substr(name,1,20) ;  *throws error;
  y=substrn(name,1,20) ;  *works without error;
run;

No, I don't think there is an easy way to specify this specific error should not trigger an Exit status.  There are options for handling errors, and you can force a successful return status, but generally you don't have the granularity to limit which specific problems effect the return status.  I think it will be easier to avoid the error by adapting your code to prevent it from occurring.

BASUG is hosting free webinars Next up: Mike Raithel presenting on validating data files on Wednesday July 17. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

View solution in original post

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Fix your code.  There is a reason why warnings and errors come out in the log.  In this example you have a substr() call with either a missing third value, or a value which is too long for the text string.  This would be an error and may affect results, hence its a very good idea to fix it.

gamotte
Rhodochrosite | Level 12

Hello,

 

You can use the substrn function.

 

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002255112.htm

 

Quote :

The following information applies to the SUBSTRN function:

  • The SUBSTRN function returns a string with a length of zero if either position or length has a missing value.

  • If the position that you specify is non-positive, the result is truncated at the beginning, so that the first character of the result is the first character of the string. The length of the result is reduced accordingly.

  • If the length that you specify extends beyond the end of the string, the result is truncated at the end, so that the last character of the result is the last character of the string.

Quentin
Super User

I would say that is an error.  It's just unfortunate that SAS writes a NOTE: to the log rather than an ERROR: message.  This is one of many notes that are really errors.

 

That said, first question would be what value is causing the problem fro SUBSTR()?  Note that there is a SUBSTRN() function which will accept some arguments that are invalid arguments for SUBSTR().  For example, if the third argument is longer than the length of the first argument, SUBSTRN() will truncate it rather than throw an error.  Depending on the cause of your problem, SUBSTRN() might let you handle more cases without generating an error.

 

data want ;
  set sashelp.class ;
  x=substr(name,1,20) ;  *throws error;
  y=substrn(name,1,20) ;  *works without error;
run;

No, I don't think there is an easy way to specify this specific error should not trigger an Exit status.  There are options for handling errors, and you can force a successful return status, but generally you don't have the granularity to limit which specific problems effect the return status.  I think it will be easier to avoid the error by adapting your code to prevent it from occurring.

BASUG is hosting free webinars Next up: Mike Raithel presenting on validating data files on Wednesday July 17. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
BhararaTej
Fluorite | Level 6

Thank you. 

The value that is causing the issue is 'missing' and the substrn is able to handle that without generating any kind of note or warning in the log.

SuryaKiran
Meteorite | Level 14

You may need to run the substr on condition to avoid warnings for the records that don't meet the substr criteria. 

 

If you just want to ignore that notes then set OPTIONS ERRORS=0;

Thanks,
Suryakiran
Reeza
Super User

@BhararaTej wrote:

I am running a program which is scheduled through the SAS Management Console and usually I get email notifications if the program ran successfully (Done Status) or did it Exit (meaning SAS says it had some issues). These email triggers are auto generated through the Management Console. 

 

Now, one of my programs is generating an Exit Status because of below 2 lines. But these are not actually errors, but just warnings and the program is fine. I am trying to figure out if there is a way for me to have SAS suppress/ ignore certain type of these warnings, so that I can have Management console generate a Success Status notification and not Exit.  

 

NOTE: Invalid third argument to function SUBSTR at line 554 column 12.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed. 

 

--Tb


If you suppress those errors how will you know when you actually have an error or incorrect parameter passed? If there's something in the data where that shouldn't be calculated wrap that calculation in an IF statement so it's conditional. A clean log is a good practice.

BhararaTej
Fluorite | Level 6

Thank you. Yea, Given that I know now that the missing value was causing the issue, I should have wrote a conditional if statement to have the substr calculate only on populated values. 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 7 replies
  • 4954 views
  • 4 likes
  • 6 in conversation