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
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.
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.
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.
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.
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.
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;
@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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.