Desktop productivity for business analysts and programmers

SAS Custom Warnings

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

SAS Custom Warnings

Is it  possible, in either SAS 9.4 or SAS enterprise, to create a custom warning?  For example, my friend and I were thinking out loud that it would be helpful having SAS give a warning when I do a RIGHT JOIN in proc SQL, because this is something that could have dreadful consequences if it was used incorrectly.  It could say "warning: You are doing a Right Join! "    


Accepted Solutions
Solution
‎03-27-2018 10:40 AM
SAS Super FREQ
Posts: 381

Re: SAS Custom Warnings

[ Edited ]
Posted in reply to TimWright

Yes, you can print custom warnings (or errors or notes) to the SAS log via put statements in SAS code. For example, if you submit this somewhere in your SAS code...

 

%put WARNING: You are doing something I need to warn you about!;

 

...it will show up in the log and the log summary view, like so:

customWarning.png

 

(Use "%put ERROR: error text;" or "%put NOTE: note text;" for custom errors or notes.)

 

Granted, you'd have to be able to detect the scenario you wish to warn via code, so your code knows when to conditionally print the warning. That might be difficult with the example you mentioned.

 

Casey

View solution in original post


All Replies
Solution
‎03-27-2018 10:40 AM
SAS Super FREQ
Posts: 381

Re: SAS Custom Warnings

[ Edited ]
Posted in reply to TimWright

Yes, you can print custom warnings (or errors or notes) to the SAS log via put statements in SAS code. For example, if you submit this somewhere in your SAS code...

 

%put WARNING: You are doing something I need to warn you about!;

 

...it will show up in the log and the log summary view, like so:

customWarning.png

 

(Use "%put ERROR: error text;" or "%put NOTE: note text;" for custom errors or notes.)

 

Granted, you'd have to be able to detect the scenario you wish to warn via code, so your code knows when to conditionally print the warning. That might be difficult with the example you mentioned.

 

Casey

Occasional Contributor
Posts: 16

Re: SAS Custom Warnings

Posted in reply to CaseySmith
Yes. I see that programming it would be tricky. But I see what you mean. You would just use a conditional %put statement . Thanks
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 157 views
  • 0 likes
  • 2 in conversation