Hey Guys pardon me I am again raising this old issue. Actually I am not able to get the expected result, for that I am again posting this issue. This time more broadly I am expressing this, I will expect some hopeful help from you,
Suppose I have this sort of sample code
Data Test;
Input Name $ Class;
Datalines;
Amm 5
Jmm 6
Tmm 7
Pmm 8
;
Run;
This code will give me the following output
Super!
Now, suppose I am using this wrong code.
Data Test;
Input Name $ Class;
Amm 5
Jmm 6
Tmm 7
Pmm 8
;
Run;
After execution of this code, I will get following error.
Here we can see two types of error.
One with error code "ERROR 180-322: Statement is not valid or it is used out of proper order."
Another without error code "ERROR: No DATALINES or INFILE statement."
My concern is I want to get mail respect to particular error massage from SAS Log, any how. But I need to mention the error massage there, I mean to say, that only respect to the error text for example here "Statement is not valid or it is used out of proper order." I want to get one mail.
Please suggest me one helpful way to do that. I am trying to do that in many way, but I am failing to do that, we can save the log and then read that log, from there we can send mail, but respect to one particular text I am not able to do that, I van do respect to error code.
I need your support here.
Thank you
Regards
Sourav
Send the log containing the ERROR and let the programmer figure out what's wrong. That's why we humans are still needed, and can't be replaced by a few grams of silicone.
Hey Kurt,
Thanks for your advice, I need some process that way I defined, is there any way, I can do that? Basically the error I am facing that is a different deal, there I need this process I am talking about, so please if you really can help me about sending mail on particular error text then help me.
Regards
Sourav
I see you're still trying to crack this nut.
My advice from the earlier thread:
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.
Thanks for loo into my issue, for example I have used this code and the error to show what is my issue.
I tried to save the SAS log in to some different place, tried to read the log or scan the log, use SYSERR or SYSERRORTEXT, but I am stucking in to one place, I am not able to define the error statement in the condition. Can you try for me once, and check you are able to send any mail respect to any error statement, not error code, I can send mail respect to error code like here 180-322. Please try with the error sentence. If you can do, please share the sort of code. I am struggling with issue from a long time, you can see my previous posts.
Thanks.
Regards
Sourav
Hi Guys,
If you get any resolution respect to the particular issue I am facing, I will be glad if I could solve this issue as early as possible. I am trying for a long time.. Now I have to solve this issue.
Regards
Sourav
It's now HIGH time you reconsider your situation and start with a new design. There seems to be no solution along the way you are thinking.
Please check this following code...
Filename _log_ "/home/sourav/test.log";
Data Log1;
Infile _log_ truncover;
input a_line $200.;
If Substr(Scan(a_line,1,','),56) = 'Statement is not valid or it is used out of proper order.'
/*if error = SUBSTR(Scan(a_line, 'Statement is not valid or it is used out of proper order.') > 0 */
then;
/*index(a_line, 'WARNING') > 0*/
filename myfile email
to= "sourav_email@email.COM"
subject= "Error in Report"
type= "text/plain"
importance="HIGH";
data _null_;
file myfile;
put 'Dear User';
put;
put 'Due to your selection you are getting this mail.';
put;
put 'Please go with some short selction.';
run;
I am using this code, here you can see I am trying get the mail on particular one statement, but my fault is that this scan statement is not able to scan that entire statement. Please suggest me one way, where I can read the whole statement. If that stamen will not be in the log I will not get any mail, else if it will be there, I will get mail.
Regards
Sourav
Looking at the error email text you want to send it's eventually important to be very clear about what you're trying to do.
One area would be about writing a program/application which takes user input (not from programmers but from business users). In such a case you would want to make sure that whatever the user inputs can't break your program. For this reason you would implement some validation of the passed in values and in case they are invalid you create an error/exception report and you might send messages/emails back to the user. This is a fully controlled situation and your actual program won't break. It might stop or even abort but that's something you've anticipated and coded for.
The other case is when something unexpected happens and your program falls over uncontrolled. In such a case anything can happen. You can try to implement some post code in your program which then sends out an email BUT because this is an uncontrolled situation you can't be sure (and never will) if your program will even reach the point of sending out emails after the error occurred.
For this reason the only safe method to deal with such errors is having another process (parent process or independent monitoring process) monitoring the job return code. If the return code is not "success" then you can program to take action (i.e. send an email to the process owner and attach the log of the failed program to the email).
I wouldn't try to also parse the log and tell the user what the error is - also because sometimes things go that wrong that the error message isn't really telling you what went wrong. Someone needs to investigate.
Thanks Patrick for your observation on this issue. What are you suggesting me to do right now? I ca not discuss the coding matter with user. The situation is like, I am running code not in local machine. I running the code in client server, there for some code if we go all selected value from certain validation or we can say prompts, they for that output we dont have much space, during the execution of that code we are getting error due to space issue, there we are working on to increase the space, or to set some other space in unix folder. But till now we need a solution, like if that error (particularly only that space related error, not other error) will occur, then we will send mail to user for less selection and run the report again. I ma trying to create one macro on that.
I showed you one sort of code for example, how am I trying to execute the process. I hope now you have an idea, what is the thought behind the coding, I am requesting you guys, please help me out here to get one possible solution on this. Please dont say anything about space related issue, because that is client matter, we have requested for more space to run the report smoothly.
Please suggest me some way how can I hard code this issue. I am trying to do this as discussed with client.. If you help me on this, it will be helpful for me to temporary process improvement.....
Regards
Sourav
Get a grasp on the range of input that can be computed with the resources you have. Then only allow such combinations, and return a proper message if capabilities are exceeded. Only THEN run the code.
If you want to have a controlled situation then you need to implement a validation step which calculates the estimated disk space required based on input variables passed in, then checks the available disk space and then only executes the reporting code if there is sufficient space available or else sends out the email and doesn't execute.
With out of space issues your program will likely not be able to continue execution and though going for some post code sending out an email is likely not going to work as desired.
If there is not enough disk space available (WORK?) then also consider:
1. Clean-up: Are there left overs from old sessions (i.e. failed SAS EG sessions). If yes then delete these orphaned session folders.
2. Can you reengineer your reporting code so it consumes less resources?
If you've done already what you can then I wouldn't spend more time on trying to solve an issue which is not under your control (insufficient disk space).
Patrick
Thank you for your closely observation on this issue. Can you suggest me a work around here, and how do I complete this process.
Thanks & Regards
Sourav
@Patrick already gave you the path for the workaround, I quote from his post:
"If you want to have a controlled situation then you need to implement a validation step which calculates the estimated disk space required based on input variables passed in, then checks the available disk space and then only executes the reporting code if there is sufficient space available or else sends out the email and doesn't execute."
This will mean that you have to analyze your code, which combinations of input it can reliably execute on, and which combinations will make it fail. This of course will involve lots of test runs.
Once you have that information, you could (as an example) build a dataset with all possible input combinations, mark those as valid/non valid, and in the STP check the user's input against that, and from that decide to go on or respond with a failure message.
Thanks Kurt
Can you explain some way in coding, how can I do that, I am not getting any idea, how to do that.
Regards
Sourav
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.