BookmarkSubscribeRSS Feed
redspring
Calcite | Level 5

Hi All SAS users,

 

I am looking for SAS code that can combine proc lifereg with Weibull distribution and proc mianalyze and the proc lifereg starts with the intercept only and adds one variable a time until all variables of interest are added.

 

I have spent some time searching so far nothing addressing all of the above requirements are found.

 

Could anyone of you provide the SAS codes or point me to the existing postings or paper please?

 

Thank you very much in advance.

 

12 REPLIES 12
sbxkoenk
SAS Super FREQ

So, you have several Weibull analyses :

  • an intercept-only model and then
  • a model with intercept +1 explanatory var and then
  • a model with intercept +2 explanatory vars and then 
  • a model with intercept +3 explanatory vars and then 
  • ...

All made with LIFEREG procedure. Correct?

 

What do you want to achieve with PROC MIANALYZE ??

PROC MIANALYZE is to combine results after multiple imputation (and after having one model result per multiple imputation instance).

 

PROC MI is a companion procedure.
You need to use PROC MI and PROC MIANALYZE together.

See here :

Maybe this paper helps you out :
PharmaSUG 2017 - Paper SP05
Combining Survival Analysis Results after Multiple Imputation of Censored
Event Times
Jonathan L. Moscovici, QuintilesIMS, Montreal, QC
Bohdana Ratitch, QuintilesIMS, Montreal, QC
https://www.pharmasug.org/proceedings/2017/SP/PharmaSUG-2017-SP05.pdf

 

BR,

Koen

redspring
Calcite | Level 5

Thank you Koen for your kind reply.

 

Yes. I start with an intercept only model and add one variable a time and all made with LIFEREG procedure.

 

I want to combine the fit statistics obtained from the proc lifereg with dist=Weibull and I am struggling with the options for the statement of modeleffects and stderr of proc mianalyze. 

 

Yes. I have used proc mi to generate a multiply imputed dataset which is the input dataset for proc lifereg.

 

Thank you for sharing that paper. I already read the SAS code from that paper before I posted my question.

 

Any further suggestion/comments?

 

The other thing is if I perform proc lifereg one by one then my sas program would be very long. I was wondering if you can suggest a macro structure for this task. Please also suggest.

 

Thanks again.

Rick_SAS
SAS Super FREQ

> Any further suggestions/comments?

Please post the SAS code that you have written so far. Sample data is also appreciated. That will enable us to suggest the best way to answer your questions.

redspring
Calcite | Level 5
Thank you Rick.

Please see my code below: I run it and I found the pvalue_comb is blank in the final output table. Is it right if it is blank? Please further suggest.

ods output parameterestimates=FS_interceptonly;
/*start with an intercept only model*/
proc lifereg data=rand_all;
model Time_fup*Outc_diab(0)= / d=weibull;
by _imputation_;
run;

data FS_interceptonly1;
set FS_interceptonly;
if _Imputation_=1;
VarSeq=_N_;
keep Parameter varseq;
run;

proc sql;
create table FS_interceptonly_seq as
select a.*, b.VarSeq
from FS_interceptonly as a left join FS_interceptonly1 as b
on a.Parameter=b.Parameter
order by varseq, Parameter, _Imputation_ ;
quit;

ods output ParameterEstimates=mianal_interceptonly;
proc mianalyze data= FS_interceptonly_seq;
modeleffects estimate ;
stderr StdErr;
by VarSeq;
run;

proc sql;
create table mianal_interceptonly2 as
select a.*, b.Parameter
from mianal_interceptonly as a left join FS_interceptonly1 as b
on a.VarSeq=b.VarSeq ;
quit;


data mianal_interceptonly_out ;
retain Parameter Probt Nimpute ;
set mianal_interceptonly2;
rename Probt=pvalue_comb;
keep Parameter Nimpute Probt;
run;
SAS_Rob
SAS Employee

Without seeing the LOG it is hard to say what is going wrong, but it is not clear to me why you have the SQL step in between LIFEREG and MIANALYZE.  My suggestion is to use the ODS OUTPUT statement to capture the ParameterEstimates table and feed that into MIANALYZE.  See the example below:

 

data motors;
input time censor temp @@;
if _N_=1 then
do;
temp=130;
time=.;
control=1;
z=1000/(273.2+temp);
output;
temp=150;
time=.;
control=1;
z=1000/(273.2+temp);
output;
end;
if temp>150;
control=0;
z=1000/(273.2+temp);
output;
datalines;
8064 0 150 8064 0 150 8064 0 150 8064 0 150 8064 0 .
8064 0 150 8064 0 150 8064 0 150 8064 0 150 8064 0 150
1764 1 170 2772 1 170 3444 1 170 3542 1 170 3780 1 170
4860 1 170 5196 1 170 5448 0 170 5448 0 170 5448 0 170
408 1 190 408 1 190 1344 1 190 1344 1 190 1440 1 190
1680 0 190 1680 0 190 1680 0 190 1680 0 190 1680 0 190
408 1 220 408 1 220 504 1 220 504 1 220 504 1 220
528 0 220 528 0 220 528 0 220 528 0 220 528 0 220
;
proc mi data=motors nimpute=10 out=motors_imp;
var time censor z;
run;


proc lifereg data=motors_imp;
model time*censor(0)= /dist=weibull;
by _imputation_;
ods output ParameterEstimates=parms;
run;;
proc mianalyze parms=parms;
modeleffects intercept;
run;

 

 

redspring
Calcite | Level 5

Thank you Rob. 

 

I have tried your suggestion and found it works.

 

I also found I could not use the stderr statement in proc mianalyze but I still got the StdErr in the output of proc minanalyze and the combined probability becomes blank. The LCLMean and the UCL mean become blank as well.

 

Could you please suggest what I have found makes sense?

redspring
Calcite | Level 5

Thanks Rob again.

 

Please see the log below and further suggest.

 

1 The SAS System 19:34 Wednesday, November 2, 2022

1 %_eg_hidenotesandsource;
MPRINT(_EG_HIDENOTESANDSOURCE): options nonotes;
MPRINT(_EG_HIDENOTESANDSOURCE): options nosource;
MPRINT(_EG_RESTORENOTESANDSOURCE): options NOTES;
MPRINT(_EG_RESTORENOTESANDSOURCE): options SOURCE;
5 %_eg_hidenotesandsource;
MPRINT(_EG_HIDENOTESANDSOURCE): options nonotes;
MPRINT(_EG_HIDENOTESANDSOURCE): options nosource;
MPRINT(_EG_RESTORENOTESANDSOURCE): options NOTES;
MPRINT(_EG_RESTORENOTESANDSOURCE): options SOURCE;
41
42 /*start with an intercept only model*/
43 proc lifereg data=test;
44 model Time_fup*Outc_diab(0)= / d=weibull;
45 by _imputation_;
46 ods output parameterestimates=FS_interceptonly;
47 run;

NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=1
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=2
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=3
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=4
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=5
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=6
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=7
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=8
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=9
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=10
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=11
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=12
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=13
NOTE: Algorithm converged.
2 The SAS System 19:34 Wednesday, November 2, 2022

NOTE: The above message was for the following BY group:
Imputation Number=14
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=15
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=16
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=17
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=18
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=19
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=20
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=21
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=22
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=23
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=24
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=25
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=26
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=27
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=28
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=29
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=30
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=31
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=32
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
3 The SAS System 19:34 Wednesday, November 2, 2022

Imputation Number=33
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=34
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=35
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=36
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=37
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=38
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=39
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=40
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=41
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=42
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=43
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=44
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=45
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=46
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=47
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=48
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=49
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=50
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=51
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=52
4 The SAS System 19:34 Wednesday, November 2, 2022

NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=53
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=54
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=55
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=56
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=57
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=58
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=59
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=60
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=61
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=62
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=63
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=64
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=65
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=66
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=67
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=68
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=69
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=70
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=71
NOTE: Algorithm converged.
5 The SAS System 19:34 Wednesday, November 2, 2022

NOTE: The above message was for the following BY group:
Imputation Number=72
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=73
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=74
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=75
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=76
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=77
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=78
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=79
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=80
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=81
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=82
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=83
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=84
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=85
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=86
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=87
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=88
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=89
NOTE: Algorithm converged.
NOTE: The above message was for the following BY group:
Imputation Number=90
NOTE: The data set WORK.FS_INTERCEPTONLY has 360 observations and 9 variables.
NOTE: The PROCEDURE LIFEREG printed pages 1-90.
6 The SAS System 19:34 Wednesday, November 2, 2022

NOTE: PROCEDURE LIFEREG used (Total process time):
real time 14.85 seconds
cpu time 14.92 seconds

48
49
50 ods output ParameterEstimates=mianal_interceptonly(rename= (Probt=pvalue_comb));
51
51 ! proc mianalyze parms= FS_interceptonly;
52 modeleffects intercept ;
53 run;

WARNING: Between-imputation variance is zero for variable intercept.
NOTE: The data set WORK.MIANAL_INTERCEPTONLY has 1 observations and 12 variables.
NOTE: The PROCEDURE MIANALYZE printed page 91.
NOTE: PROCEDURE MIANALYZE used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

54
55 %_eg_hidenotesandsource;
MPRINT(_EG_HIDENOTESANDSOURCE): options nonotes;
MPRINT(_EG_HIDENOTESANDSOURCE): options nosource;
MPRINT(_EG_RESTORENOTESANDSOURCE): options NOTES;
MPRINT(_EG_RESTORENOTESANDSOURCE): options SOURCE;
70
71
72 %_eg_hidenotesandsource;
MPRINT(_EG_HIDENOTESANDSOURCE): options nonotes;
MPRINT(_EG_HIDENOTESANDSOURCE): options nosource;
MPRINT(_EG_RESTORENOTESANDSOURCE): options NOTES;
MPRINT(_EG_RESTORENOTESANDSOURCE): options SOURCE;
75

SAS_Rob
SAS Employee

You will notice that there is a WARNING message in the Proc MIANALYZE step:

WARNING: Between-imputation variance is zero for variable intercept.

 

The message you are receiving can have a number of possible causes.  The first is that there is some problem with the imputation model itself (I have seen where people have left the response variable off the VAR statement in Proc MI as an example).  In general, though it occurs when the missing data has no influence on the sampling error of a parameter estimate.  There is no fix or adjustment for that, but it does require some further investigation on your part.  Usually, it is an indication of a problem with the imputation model with possible causes ranging from a poor imputation model to no real need to impute due to a very small fraction of missing information  

 

Without fixing the problem, when the between imputation variance is zero then the number of Degrees of Freedom is undefined so you cannot get a confidence interval or p-values.  If you are unable to determine the cause then one suggestion would be that, if there are only minimum differences among these within-imputation variances, then look at the results for that variable for one of the imputations. 

redspring
Calcite | Level 5
Thank you for your further response. I will investigate as per your suggestion.
sbxkoenk
SAS Super FREQ

@redspring wrote:

 

The other thing is if I perform proc lifereg one by one then my sas program would be very long. I was wondering if you can suggest a macro structure for this task. Please also suggest.


Hello,

Only a single MODEL statement can be used with one invocation of the LIFEREG procedure.

But if you have multiple models, you can do something like this :

 

Replace :

proc lifereg data=motors outest=modela covout;
   a: model time*censor(0)=z;
      output out=outa quantiles=.1 .5 .9 std=std p=predtime
         control=control;
run;

proc lifereg data=motors outest=modelb covout;
   b: model time*censor(0)=z / dist=lnormal;
      output out=outb quantiles=.1 .5 .9 std=std p=predtime
         control=control;
run;

BY THIS ( !! untested !! ) :

PROC DATASETS LIBRARY=WORK NoList memtype=CATALOG;
 delete t ; run;
QUIT;

filename tt CATALOG 'work.t.t.source';

data work.tobeinserted;
LENGTH modellabel $ 2 modelstmt $ 50;
modellabel='a'; modelstmt='model time*censor(0)=z;';                output;
modellabel='b'; modelstmt='model time*censor(0)=z / dist=lnormal;'; output;
run;

data _NULL_;
 set work.tobeinserted end=lastobs;
 file tt;
 if _N_=1   then do; /*do nothing */ end;
PUT 'proc lifereg data=motors outest=model' modellabel ' covout;';
PUT modellabel +(-1) ': ' modelstmt ;
PUT ' output out=out' modellabel ' quantiles=.1 .5 .9 std=std p=predtime';
PUT '        control=control;';
PUT 'run;';
 if lastobs then do; /*do nothing */ end;
run;
/* end of program */

%INCLUDE tt / source2;
filename tt CLEAR;

For lots of models, it's less coding then writing out all PROC LIFEREGs. 😉

 

Koen

 
redspring
Calcite | Level 5

Thank you Koen for your effort.

 

Your code must be helpful in reducing the redundancies.

 

I will use it when I see a fit.

 

Thank you again.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 12 replies
  • 831 views
  • 0 likes
  • 4 in conversation