BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
pmbrown
Quartz | Level 8

unfortunately Rick Wicklin's neat solution here: https://communities.sas.com/t5/Statistical-Procedures/NLMIXED-difference-between-convergence-status-...

 

does not work for this scenario: https://communities.sas.com/t5/Statistical-Procedures/proc-phreg-ties-handling-floating-point-zero-d...

 

i'm wondering how to catch the error in a dataset when running a large macro containing several phreg's. Can Rick's code be modified in some way? That would be ideal because i am already making use of it

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

@pmbrown wrote:

excellent, i will try this asap. 

i think syserr has been useful for me when catching the non-poitive definite warning message, so maybe i need a combination of syserr and detecting if parameterestimatesdata exists

 Yes, that's a good idea to check both.  Something like:

%if &syserr=0 and %sysfunc(exist(&ParameterEstimatesData)) %then %do; 
...
The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

View solution in original post

18 REPLIES 18
JosvanderVelden
SAS Super FREQ
Both threads you mention are marked as solved. Can you elaborate on why Rick's solution doesn't work for the scenario from the second post. Are you using the latest SAS 9.4 release (SAS 9.4M8 shipped in January 2023) or an older release?
pmbrown
Quartz | Level 8

it doens't work for the scenario metioned, i don't know why.

re version: i'm not looking to solve the problem, i am  only looking to catch it

re they are marked as solved: that's why i had to create a new thread, they are closed (unfortunately)

sbxkoenk
SAS Super FREQ

Hello,

 

What procedure are you using? PROC PHREG?

 

I do not think there's any mentioning of "floating point zero divide error" in the output. So, ODS (Output Delivery System) solutions are impossible. 

You will have to parse the log.

If you have BY-groups , analyzing the LOG by means of a self-written LOG-Analyzer ... should tell you which BY group to look at.

 

Koen

pmbrown
Quartz | Level 8

re ods solutions are impossible: that's right, it won't show up in the covergencestatus ods

re parse the log: but i need to catch it in a dataset, that's what's great about Rick Wicklin's solution, and i'm wondering how to adjust his code to catch this error, because it does not catch it

JosvanderVelden
SAS Super FREQ
Can you describe the scenario where it does not catch it, with a small data and code example?
pmbrown
Quartz | Level 8

sure

proc phreg data=...;
  class groupvar (ref=first) arm  / param=ref;
  model aval*cnsr(1,2)= groupvar arm  / risklimits=pl ties=exact; 
  ods output ParameterEstimates=.... ;
  estimate 'G1' groupvar 1 /cl exp; 
run;

 

NOTE: Convergence criterion (GCONV=1E-8) satisfied.
ERROR: Floating Point Zero Divide.
WARNING: Output 'ParameterEstimates' was not created.  Make sure that the output object name, label, or path is spelled correctly.  
         Also, verify that the appropriate procedure options are used to produce the requested output object.  For example, verify 
         that the NOPRINT option is not used.
ERROR: Termination due to Floating Point Exception
NOTE: The SAS System stopped processing this step because of errors.
NOTE: The PROCEDURE PHREG printed pages 157-158.
NOTE: PROCEDURE PHREG used (Total process time):
      real time           0.69 seconds
      cpu time            0.69 seconds

i can't give data, it may be the case that the event rate is low, but i'm not at all interested in that, i am only interested in how i can catch this error in a dataset

 

Quentin
Super User

When try to use Rick's solution, what happens? It's not clear to me what you mean by it does not work.  His solution is storing the value of the automatic macro variable &SYSWARNINGTEXT.  If you want to store the error message, you could change the macro call to:

%MonitorErrors(1, &SysErr, "&SysErrorText")

 But as a more basic test, can you post the full log from running:

proc phreg data=...;
  class groupvar (ref=first) arm  / param=ref;
  model aval*cnsr(1,2)= groupvar arm  / risklimits=pl ties=exact; 
  ods output ParameterEstimates=.... ;
  estimate 'G1' groupvar 1 /cl exp; 
run;

%put &=SysErr &=SysWarningText &=SysErrorText ;

As long as PROC PHREG is appropriately setting SYSERR to a non-zero value, I think Rick's method should work.  But if PHREG is not setting SYSERR, then you might have to resort to log scanning, or checking for the existence of the output ParameterEstimates data set. If you're running the code as a batch job, it's possible the error is causing the SAS session to abort, but there are options to change that.  And that is not shown in the log messages you posted.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
pmbrown
Quartz | Level 8

apparently syserr is 0 because it's resulting in msg=OK for everything, ie i run the model for many scenarios and it always reports syserr=0 even when there is an error. Like this:

SYSERR=0 SYSWARNINGTEXT=Output 'ParameterEstimates' was not created.  Make sure that the output object name, label, or path is 
spelled correctly.  Also, verify that the appropriate procedure options are used to produce the requested output object.  For 
example, verify that the NOPRINT option is not used. SYSERRORTEXT=Termination due to Floating Point Exception

the solution then seems to be to collect syserrortext, as you suggested, regardless of the value of syserr, and then use the index function (or whatever) to scan the text. Edit: or Tom's suggestion re checking for the parametestimates dataset

Quentin
Super User

That's unfortunate that SYSERR is not being set when there is an error.  I recommend you submit that to tech support as a bug.

 

The tricky thing about SYSERRORTEXT and SYSWARNINGTEXT is that they are not reset to blank at a step boundary.  So you can't simply test the value of these variables.  But probably you could use the existence of the parameterestimates output dataset as the switch instead of syserr.  So something like:

 

%macro MonitorErrors(ModelID, ParameterEstimatesData, Text);
   data ErrorMsg;
      length msg $200;
      ModelID = &ModelID;
      %if %sysfunc(exist(&ParameterEstimatesData)) %then %do;
         msg = "OK";
      %end;
      %else %do;
         msg = &Text;
      %end;
   run;
   proc append base=Errors data=ErrorMsg force; run;
%mend;

With that approach, assuming you're running multiple PHREG steps, you would need to PROC DELETE the parameter estimates data after each step.  You could do that with the above macro, or outside of it.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
pmbrown
Quartz | Level 8

excellent, i will try this asap. 

re they are not reset to blank, i just noticed this, ie there's is one model causing the problem, but the errors i capture suggest every model after this problem model is a problem, as if the value is retained

i think syserr has been useful for me when catching the non-poitive definite warning message, so maybe i need a combination of syserr and detecting if parameterestimatesdata exists

Quentin
Super User

@pmbrown wrote:

excellent, i will try this asap. 

i think syserr has been useful for me when catching the non-poitive definite warning message, so maybe i need a combination of syserr and detecting if parameterestimatesdata exists

 Yes, that's a good idea to check both.  Something like:

%if &syserr=0 and %sysfunc(exist(&ParameterEstimatesData)) %then %do; 
...
The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
data_null__
Jade | Level 19

You can sort of reset SYSERRORTEXT.  

 

101  data _null_;
102     set notfound;
ERROR: File WORK.NOTFOUND.DATA does not exist.
103     run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


104  %put NOTE: &=syserrortext;
NOTE: SYSERRORTEXT=File WORK.NOTFOUND.DATA does not exist.
105  %put ERROR: %str( );
ERROR:
106  %put NOTE: &=syserrortext;
NOTE: SYSERRORTEXT=
Quentin
Super User

@data_null__ wrote:

You can sort of reset SYSERRORTEXT.  

 

101  data _null_;
102     set notfound;
ERROR: File WORK.NOTFOUND.DATA does not exist.
103     run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


104  %put NOTE: &=syserrortext;
NOTE: SYSERRORTEXT=File WORK.NOTFOUND.DATA does not exist.
105  %put ERROR: %str( );
ERROR:
106  %put NOTE: &=syserrortext;
NOTE: SYSERRORTEXT=

Wow, thanks DN, that's just the kind of insightful tidbit that makes SAS communities so valuable. You never know what you will learn by participating in a discussion thread.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
pmbrown
Quartz | Level 8

i accept this as the solution, although it turns out that when the floating point error occurs it terminates the program. I was hoping it would continue to run analyses with the problem analysis flagged, but i need to write code to detect when a problem analysis might arise and prevent it from running. For what it's worth i will continue using the macro to catch warnings

 

%macro monitorerrs(modelID,errornum,ParameterEstimatesData);

data errmsg&modelID;
  length msg $200;
*put model ID and syserr in dataset;
  modelID = &modelID;
  syserr = &errornum;
*put message in dataset;
  %if &errornum gt 0 %then %do;
      msg = "&SysWarningText"; /*eg, pos def, ridging etc*/
  %end;
  %else %if %sysfunc(exist(&ParameterEstimatesData)) %then %do; 
     msg = "OK";
  %end;
  %else %do;
      msg = "&SysErrorText";
  %end;
run;

%mend monitorerrs;

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 18 replies
  • 3567 views
  • 9 likes
  • 6 in conversation