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

Hi, guys. I would like to study the mean difference in the number of relapse among the three treatment groups. Because the data set was partially missing, after using multiple imputation, 100  imputation sets were obtained.

After using pro genmod analysis, I want to use the nlmeans macro to compare the comparison results of each imputation set.  But the following result is prompted. Do you know why?

 

here is my data

imputation      id      relapse_count    lntime   group

1                          1             0                        -1             1

1                          2             2                       -3             2

.....

100                    33            3                       -4             3

 

here is my SAS code:

stype1:
proc genmod data=relapse;
class group(ref="1") id/param=glm;
model relapse_count=group/link=log dist=negbin offset=lntime;
repeated subject=id;
lsmeans group/ilink cl e;
estimate 'group2 vs 1 of RR' group -1 1 0/e;
estimate 'group1 vs 3 of RR' group 1 0 -1/e;
estimate 'group2 vs 3 of RR' group 0 1 -1/e;
ods output coef=coeffs;
store out=insmodel;
by _Imputation_;
run;

stype2:
%include 'path\nlest.sas';
%include 'path\nlmeans.sas';
%NLMeans(instore=insmodel, coef=coeffs, link=log, title=Difference of relapse Rates)



Here is the error:
Lucai_sister_0-1685453700392.png
here is my coeffs:
Lucai_sister_1-1685453850889.png

Am I missing a procedure? I really want researchers to help me.


 

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

As Rob suggests, to get a final combined rate estimate you need to run NLMeans on each imputation data set and then combine the results. BY processing can be done by using the NLMeans macro in the RunBY macro. This is discussed in the Details section of the NLMeans macro documentation and is illustrated in the last example in the Results tab. In your case, you should drop the ESTIMATE statements since only the LSMEANS statement is needed. Then, after downloading the RunBY macro and defining it in your session using a %INC statement, you should just need to add the following after your GENMOD step. I also suggest you make sure you are using the latest versions of the NLMeans and NLEST macro (which NLMeans calls). You can download the latest versions from support.sas.com.

%macro code;
  %nlmeans(instore=insmodel, coef=coeffs, link=log, where=&_BY1=&_LVL1, 
           options=nonames noprint, title=rate diffs)
  proc append base=alldiff data=est; run;
%mend;
%runby(data=relapse, by=_imputation_)

data alldiff; 
  set alldiff;  
  _imputation_=_n_;
  run;
proc mianalyze data=alldiff;
   modeleffects estimate;
   stderr standarderror;
   run;

 

View solution in original post

9 REPLIES 9
sbxkoenk
SAS Super FREQ

Hello,

 

Here's how you should use multiple imputation.

 

Multiple imputation inference involves three distinct phases:
  1. The missing data are filled in m times to generate m complete data sets or by-groups. (PROC MI)
  2. Perform regression or any other analysis on each of the m complete data sets or by-groups. (PROC GENMOD)
  3. Average the values of the parameter estimates across the M samples to produce a single point estimate. (PROC MIANALYZE)

After 3. you can run the macro's you need!

 

See also here:

Multiple Imputation for Missing Data: Concepts and New Development (Version 9.0)
Yang C. Yuan, SAS Institute Inc., Rockville, MD
https://support.sas.com/rnd/app/stat/papers/multipleimputation.pdf

https://support.sas.com/rnd/app/stat/topics/multiple-imputation.html

 

[EDIT] @Lucai_sister 
My answer is not entirely correct, I believe.
I am sure my colleagues @SAS_Rob and @StatDave know better, so please follow their advice.
See below for their replies!

 

Koen

 
Lucai_sister
Obsidian | Level 7
I really appreciate your advice!
SAS_Rob
SAS Employee

The %NLMEANS macro does not have a BY statement which is what you would need to make this work.  My suggestion would be to run the macro for each _imputation_ independently and then combine the estimates and standard errors into a single data set.  Once you do that you should be able to use Proc MIANALYZE to get the final combined estimates.

Lucai_sister
Obsidian | Level 7
Thank you so much!
StatDave
SAS Super FREQ

As Rob suggests, to get a final combined rate estimate you need to run NLMeans on each imputation data set and then combine the results. BY processing can be done by using the NLMeans macro in the RunBY macro. This is discussed in the Details section of the NLMeans macro documentation and is illustrated in the last example in the Results tab. In your case, you should drop the ESTIMATE statements since only the LSMEANS statement is needed. Then, after downloading the RunBY macro and defining it in your session using a %INC statement, you should just need to add the following after your GENMOD step. I also suggest you make sure you are using the latest versions of the NLMeans and NLEST macro (which NLMeans calls). You can download the latest versions from support.sas.com.

%macro code;
  %nlmeans(instore=insmodel, coef=coeffs, link=log, where=&_BY1=&_LVL1, 
           options=nonames noprint, title=rate diffs)
  proc append base=alldiff data=est; run;
%mend;
%runby(data=relapse, by=_imputation_)

data alldiff; 
  set alldiff;  
  _imputation_=_n_;
  run;
proc mianalyze data=alldiff;
   modeleffects estimate;
   stderr standarderror;
   run;

 

Lucai_sister
Obsidian | Level 7
The code works fine. Thank you so much!
lcdelta
Calcite | Level 5

I run the code below and got error. Could you please help?

 

 
proc logistic data = miout3;
by _imputation_;
class ILD MYCO TRT01P/PARAM=GLM ;
    model response(event="1") = trt01p ILD MYCO; 
    lsmeans TRT01P/e ilink diff; 
    ods output coef=coeffs LSMeans = LSMeans Diffs=Diff;
    store out=ismodel;
run; 
 
 
%macro code;
%nlmeans(instore=ismodel, coef=coeffs, link=LOGIT, where= &_BY1=&_LVL1,
           options=nonames noprint, title=rate diffs);
 
       data est; set est; 
         _imputation_=&_LVL1; 
         run;
     proc append base=alldiff data=est;
         run;
%mend;
%runby(data=miout3, by=_imputation_)
 
ERROR: The keyword parameter WHERE was not defined with the macro.
SAS_Rob
SAS Employee

Try downloading the latest version of the MACRO at link below.  The WHERE= option was added after the release of the autocall version in SAS 9.4m8.

https://support.sas.com/kb/62/addl/fusion_62362_20_nlmeans.sas.txt 

Ksharp
Super User
https://support.sas.com/kb/62/362.html

Check it at bottom of URL.
%macro code;
%nlmeans(instore=nb, coef=c, link=log, where=&_BY1=&_LVL1,
options=nonames noprint, title=rate diffs)
data est; set est;
_imputation_=&_LVL1;
run;
proc append base=alldiff data=est;
run;
%mend;
%runby(data=imput, by=_imputation_)

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
  • 9 replies
  • 1678 views
  • 9 likes
  • 6 in conversation