How do I prevent ever having OBS=0, even though an error occur.
I am not looking for a setting after or in each step, but a general statement preventing SAS in setting OBS=0.
If a SAS job in a series of SAS jobs fail i.e. &syserrortext. isn't empty, then I report/write an error message to a log. However, when an error occur then automatically SAS set OBS=0, and nothing is written to the log.
Best regards
Jens
I believe preventing SAS switching into syntaxcheck mode after an Error condition occurs wouldn't write more information about the error to the SAS log but it would continue processing data in downstream steps even after an error. That's normally not what you want to happen.
If I understand you right then you could add some logic to your macro to execute after each job some process which writes the job status information to somewhere. In this macro first store away the current values for options syntaxcheck and obs. Then set the options to nosyntaxcheck and obs=max. Write the job status to your table, then reset the options to the values you've saved away.
For storing the options use syntax like: %let sv_syntaxcheck=%sysfunc(getoption(syntaxcheck));
I don't understand what you are asking for. Having OBS option set to zero does not prevent writing to the log.
1 options obs=0; 2 data _null_; 3 put 'ERROR: My custom error message.'; 4 run; ERROR: My custom error message.
I think you are asking how to undo when SAS sets OBS=0 and syntax check mode.
Try this. I did not test. Search for SYNTAXCHECK for more info.
Options syntaxcheck=0 obs=MAX;
What type of error? Show examples from the LOG.
Sorry, I should have specified, that the log I am writing to is an external log, a MS SQL table.
I have a SAS macro executing different SAS programs, my own or from others. The macro then write the status of the execution to this extermal log (sucess/failure and optionally an error message).
However, if the error initiate an OBS = 0, nothing is written to the log.
As I beforehand don't know where and what kind of error, I need a general prevention of setting OBS = 0.
Example:
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: Due to ERROR(s) above, SAS set option OBS=0, enabling syntax check mode.
This prevents execution of subsequent data modification statements.
WARNING: The data set WORK.BACT may be incomplete. When this step was stopped there were 0
observations and 5 variables.
WARNING: Data set WORK.BACT was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
options nosyntaxcheck;
Will switch off the setting of OBS = 0.
I believe preventing SAS switching into syntaxcheck mode after an Error condition occurs wouldn't write more information about the error to the SAS log but it would continue processing data in downstream steps even after an error. That's normally not what you want to happen.
If I understand you right then you could add some logic to your macro to execute after each job some process which writes the job status information to somewhere. In this macro first store away the current values for options syntaxcheck and obs. Then set the options to nosyntaxcheck and obs=max. Write the job status to your table, then reset the options to the values you've saved away.
For storing the options use syntax like: %let sv_syntaxcheck=%sysfunc(getoption(syntaxcheck));
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.