Help using Base SAS procedures

How to change warning message in to error?

Reply
Occasional Contributor
Posts: 14

How to change warning message in to error?

Hi, in my program, I am getting warning messages when I would rather have them show up as an error message. Also, I want a warning message for a certain variable to remain as a warning, and everything else to be changed from warning to error. For example, I want all warning messages containing the variable "APPLE" to remain as a warning message, and all other warning messages with other variables to be changed to error.

I was thinking I want to write something like

If variable name contains APPLE then DKROCOND=WARNING; else DKROCOND=ERROR 

Would this work? I am not sure how to put that into SAS language..Thanks for the help!!

Super User
Posts: 11,343

Re: How to change warning message in to error?

DKROCOND is a system option and is not conditional and cannot be set for specific variables.

Where are you encountering the warnings and why is an error message preferable? Do you want to halt a process for a certain condition not involving variable "Apple"?

Occasional Contributor
Posts: 14

Re: How to change warning message in to error?

Thanks for the response. So are you saying it will be impossible to overwrite the warnings? I do not want to halt the process involving "Apple", because it is the process that runs through all the other variables. The warning involving "apple" is not important, but the warnings regarding the other variables are, and I would like it to show up as an error instead of a warning.

Super User
Posts: 11,343

Re: How to change warning message in to error?

You do need to say what you are doing when these messages are generated. In some cases and Error will halt the procedure/process.

Occasional Contributor
Posts: 14

Re: How to change warning message in to error?

I am running a data cut program, and the multiple variables that begin with "APPLE" (just an example word I chose) are actually the headings in data set, so I don't really care if the warning comes up as it has never been referenced. I get other warnings about other variables not being referenced, or something not resolved, and I would like those to show up as errors instead of warnings. The errors don't stop the program from running, it just shows up as errors in the output text file created. Therefore, I was wondering if I could somehow change the warnings for all the variables except "APPLE" to error so I can get a better idea of what is going on when I go through the output text file. Hope this wasn't too confusing. Thanks!

Super User
Posts: 11,343

Re: How to change warning message in to error?

For what you are attempting it will depend on what error you really are worried about. The "Not referenced" usually means you have a statement such as DROP KEEP or LABEL where your code is using a variable that is not in the actual data. You can test for the existence of those variables BEFORE the data step code you are running that attempts to reference them and write the specific messages of Variable X doesn't exist in dataset Y.

Example of something "not resolved" would be helpful.

Ask a Question
Discussion stats
  • 5 replies
  • 252 views
  • 0 likes
  • 2 in conversation