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;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.
Ready to level-up your skills? Choose your own adventure.