I am glad, I have learned some new error codes. But I am not able to find out the exact error code matching with my error. I have tried with couple of like 1016, 1012, 3000, 1008. But only it is working and sending mail when I am using
NE 0
I need your little bit more support, If you can help me here with the exact error code. I am using EG 7.13
Thanks
Regards
Sourav
Scroll down in the link I gave you, there's a further link to the SYSERRORTEXT automatic macro variable. Run your code so that it produces the error, and issue a %put &syserrortext; immediately after the step.
Super. With
%put &syserrortext;
This one is working. I am getting mail. But I am looking for getting mail only for the specific error
"ERROR 180-322: Statement is not valid or it is used out of proper order."
With "syserrortext" for any text type error I am getting mail. But I need user only gets mail when specific error will arrive.
ERROR: "ERROR 180-322: Statement is not valid or it is used out of proper order."
Thanks.
Regards
Sourav
Check for the substring 180-322 in &syserrortext. You can't be more specific than that.
With SYSERR and SYSERRORTEXT we can read the log error in SAS. But my point is I need to read one specific error. There I am not able to do that. For all error it is sending mail. That is not my expectation. I want to send mail respect to one single error from the LOG.
Is there any way I can do that?
Thanks
Regards
Sourav
Here I have one Sample code.
filename myfile email
to= "***.****@****.****"
subject= "Error in Report"
type= "text/plain"
importance="HIGH";
%macro errmail;
/*%if "&syserrortext" is "Statement is not valid or it is used out of proper order." %then %do;*/
data _null_;
file myfile;
put 'Your job received the following ERROR/WARNING message:';
put;
put 'ERROR was:';
put "&syserrortext";
put;
put 'WARNING was:';
put "&syswarningtext";
run;
/* %end; */
%mend errmail;
data one;
a;
run;
%put &syserr; /*or %put &syserrortext;*/
%errmail;
I am using this sample to get mail I am getting any error in the SAS Log. But I am looking for one condition there I can get mail for some specific error in Log. This is user requirement. I need to solution on urgency basis.
I am creating error in this code intentionally to get error.
Anyone has ant solution on this problem please let me know. I am trying for a long time.
Please give me the solution on code. It will be more easier for me.
Thanks
Regards
Sourav
And for the third time, previous posters have responded to you with reasoning on how you would do this in the code which is generating the issues, or by reading in the log file generated by the code which causes the issues. Neither of these you have tried to use or in most cases responded to.
I am trying all those points. But I am not getting the exact solution what I am looking for. Please see this post again and the code, I need mail on specific error text. I need to mention the error text in the code. How can I do that? Till now I did not get that resolution.
Regards
Sourav
I've combined your three topics into one. Since it's the same question and same people responding, it's most efficient for everyone if we can keep all of this together. Posting new topics just increases the number of conversations to track.
Are you trying to trigger this e-mail from within the same SAS job that triggered the error? I guess so, if you're relying on SYSERR macro vars. If so, ERROR 180-322 -- a syntax error most often caused by a missing semicolon or mismatched parentheses -- can leave the SAS session in a bad state, making it difficult for a subsequent step to be a reliable mechanism to send e-mail.
Instead, if this is critical, you would need to save the SAS log and parse it as a separate file within a separate SAS job, and then send e-mail based on the findings.
How 'bout
%if "%substr(&syserrortext,1,7)" = "180-322" %then %do;
Tons of thanks Kurt.
For this simple solution I made the thing too much complicated. I need to check with the business if it will work. Then I will come back to you again.
Thanks again for your effortless help.
Regards
Sourav
Kurt
Tons of thanks or effort. Here I have again one point in SUBSTR function. We have mentioned in the following code
%if "%substr(&syserrortext,1,7)" = "180-322" %then %do;
in the place of matrix &syserrortext, but my concern is, can I use the error text here,
Suppose I have error like
"ERROR: The SAS System stopped processing this step because of insufficient memory."
If there is no error code.
Then how can I go with that. Because in my case I have to mention the error text, there is no error code.
I need your help.
Regards
Sourav
If a SAS job crashes, just send the log, and let users figure it out. They're not babies and they don't need you to change their diapers.
If you can identify certain problems by the specific error code and the place in the program where they happen, you can make up any custom message you like.
You've gotten several examples for testing numeric codes and contents of strings already, just follow the advice.
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 16. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: