BookmarkSubscribeRSS Feed
jesseh
Calcite | Level 5

I am doing an analysis using a mixed model (PROC MIXED) on longitudinal data, wherein I'm running the model for different bootstraps/imputation combinations using a BY statement. Getting the LSMEANS from each is easy, and I can estimate the model mean AT any visit for all different values of my BY variables (bootstrap/imputation combo). SAS automatically plugs in the means of the other covariates BY the variables I have given to create different LSMEANS each time. 

 

However, one estimate of interest is the mean OVER the first six visits. For a single analysis, I have previously used an ESTIMATE statement as shown in the code below, giving equal weight over the first six visits. To produce the mean, this ESTIMATE statement needs average values of my two continuous covariates (var1 and var2) explicitly plugged in, which here are assumed to be calculated previously and stored as macro variables &mvar1 and &mvar2; it is not automatically done like in LSMEANS.

 

How can I most efficiently run the model over my BY variables (bootstrap sample/imputation combinations) using the mean of var1 and var2 for the specific bootstrap sample/imputation each time, the same way LSMEANS does automatically with the BY statement?

 

 

proc mixed data=mydata method = reml;   
   by bootn imputen;                                                
   class subj trt visit;   
   model chg = trt|visit var1 var2   / ddfm=bw solution;
   repeated visit / type=un subject=subj;
   lsmeans trt|visit/ pdiff=all cl;
	          
  estimate 'TRT 1 Over First 6 visits'
       intercept 1   
       var1 &mvar1
       covar3 &mvar2
       visit 0.166666 0.166666 0.1666666 0.166666 0.166666 0.166666 0 0 0 0
       trt 1 0 0 0
       trt*visit 0.1666666 0.166666 0.166666 0.166666 0.166666 0.166666 0 0 0 0           0 0 0 0 0 0 0 0 0 0          0 0 0 0 0 0 0 0 0 0          0 0 0 0 0 0 0 0 0 0    /CL;  

 

 

1 REPLY 1
Ksharp
Super User
I think you should post it at Stat forum.

https://communities.sas.com/t5/Statistical-Procedures/bd-p/statistical_procedures

And should use DIVISOR= option to replace 1.66667. Check the following:

proc mixed data=test;
class a b;
model y=a b a*b;
estimate 'AB12' intercept 1
a 1 0
b 0 1 0
a*b 0 1 0 0 0 0;
estimate 'avg ABij' intercept 6
a 3 3
b 2 2 2
a*b 1 1 1 1 1 1 / divisor=6;
estimate 'AB12 vs avg ABij' a 3 -3
b -2 4 -2
a*b -1 5 -1 -1 -1 -1 / divisor=6;
lsmestimate a*b 'AB12 vs avg ABij' -1 5 -1 -1 -1 -1 / divisor=6;
run;


The following could learn how to write ESTIMATE :
https://support.sas.com/kb/24/447.html

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
  • 1 reply
  • 614 views
  • 0 likes
  • 2 in conversation