BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sbampah
Fluorite | Level 6

I am running a simulation on SAS 9.4 where repeated measures count data are simulated and several  Pois/NBinomial/ZIP  regression models with random effects are fitted to the data in a sequential loop in a macro, after which  I assess parameter estimates for Power, Coverage and Bias from estimated parameters.

 

There are 5 different models that are fit to the same data in a single run of the loop, the problem is sometimes the second model does not converge because valid parameter estimates cannot be reached, which is OK, but right after this non-convergent model it invokes the no obs option and set every data set whether previously /newly created to zero observations and none of the models run again,

program stops.  I will want the program to continue running the next models.  Below is the information from SAS log :

 

NOTE: SAS set option OBS=0 and will continue to check statements. This might cause NOTE: No observations in data set.

 

I checked online and they suggest I place these codes before I run the code;

 

 options obs=max;

options replace;

options nosyntaxcheck;

 

source link below:

https://communities.sas.com/t5/General-SAS-Programming/SAS-set-option-OBS-0-and-will-continue-to-che...

 

I want to know if this will not set my sas system to a mode that will start more problems ? I will need your advice before I execute this.

Please help.

Thank you

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ErikLund_Jensen
Rhodochrosite | Level 12

Hi @sbampah 

 

It won't do any harm. I use it a lot. But you need to use it after every step, because an error in a step sets the values. You might want to reset the macro variable syscc to 0 also.

 

View solution in original post

6 REPLIES 6
ErikLund_Jensen
Rhodochrosite | Level 12

Hi @sbampah 

 

It won't do any harm. I use it a lot. But you need to use it after every step, because an error in a step sets the values. You might want to reset the macro variable syscc to 0 also.

 

sbampah
Fluorite | Level 6

Thank you for your quick response, but I want to better understand its use:

 

Assume I have a macro as follows where do I put these options:

/*Create fixed effects data outside the macro loop */
 data fixed_par;
 datalines;
    input outcome gender $ age;
    .........
    .........
;
run;
 


%sim( var1= 100,

                  var2= sim_num );


  %for %mm=1 %to  &sim_num;
           sim random effects to include on data fixed_par already created data (size 100) ;

            1.  fit proc NLMIXED MODEL ( dist=poisson );
              /*  obs option problem could occur here    */
           2. fit proc NLMIXED MODEL (dist=negbin);
                /*  obs option problem could occur here    */

          3. fit proc genmod ( gee -Poisson) ;
                  /*  obs option problem could occur here    */
          4. fit proc genmod (gee -negbin ); 
/* obs option problem could occur here */ %if %mm=&sim_num %then %do; Output appended results from 4 models. %end; %mend;

I have shown a skeletal flow of my code and where obs=0 option is usually invoked, could you let me know whether I have to do a test to know whether this error has occurred to put in the suggested solution or I should put the solution at the preamble of code.

 

You help would be appreciated.

Thank you in advance. 

ErikLund_Jensen
Rhodochrosite | Level 12

Hi @sbampah 

 

SAS works in steps. A step is either a data step (starting with keyword data  and ending with run;) or a proc step (starting with keyword proc and ending with run/quit);

 

If a step fails, SAS writes red error messages in the log and set the mentioned options to values that prevent execution of further steps.  It does so to prevent waste of ressources and to secure that data sets created in following steps are not overwritten with bad data from the failed step.

 

By resetting the options SAS executes the next step, which might fail, but resetting the options causes SAS to execute the third step and so on.... It can be useful if the steps are independent, like reading many files in a series of steps, but one has to be careful if data are processed through several steps. 

 

It follows that options should be reset after the step that might fail, I cannot figure out exactly what your skeleton code does, but a proper place seems to be before the append step.

 

 

 

 

sbampah
Fluorite | Level 6

Thank you very much.  There is a little dependence here , it there are errors in a step then I need to have an if statement to set expected output data from that step to missing and reset options. Do you have any suggestions of how I can test for errors in a proc step to know obs=0 is invoked ?:

 

     My thoughts:

  if &syscc ge 4 then do;

 Will this work good or I need to use _Error_  ?

 

Any suggestions would be appreciated. 

 

Thank you once again. 

 

Kurt_Bremser
Super User

Put these options in the header of this particular program/project. Do not use them in any global autoexec, or you risk unwanted serious damage to existing datasets when ERRORs do not prevent a program from working on.

HappySASUE
Quartz | Level 8

Hi I am doing exactly the same research to yours.  Similar methods and same error.  Could you please tell me your final solution/code? Thanks. 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 6747 views
  • 3 likes
  • 4 in conversation