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

I run a mixed model according to the PROC MIXED step in SAS. My code is like this below:

proc mixed data=inds;
   class subject arm(ref='C组(对照组)') ;
   model aval =base arm avisitn arm*avisitn /s ;
   random subject ;
   repeated /  subject=subject ;
   lsmeans arm / diff cl at avisitn=0;
   lsmeans arm / diff cl at avisitn=1;
   lsmeans arm / diff cl at avisitn=2;
   ods output  diffs=diff ;
run;

Then I change the variable in the model option at the left side of the equation like this:

proc mixed data=inds;
   class subject arm(ref='C组(对照组)') ;
   model chg =base arm avisitn arm*avisitn /s;
   random subject ;
   repeated / subject=subject ;
/*   lsmeans arm / pdiff cl at avisitn=0;*/
   lsmeans arm / pdiff cl at avisitn=1;
   lsmeans arm / pdiff cl at avisitn=2;
   ods output  diffs=diff1 ;
run;

I just change the variable from the value at each time point to the change from baseline. Then I find that the Differences of Least Squares Means is the same. I do not know how this works. Can anyone tell me why?

A explanation from the model and a suggestion from the code so that I can see why I get the same results.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@XixiHaha wrote:

I just change the variable from the value at each time point to the change from baseline. Then I find that the Differences of Least Squares Means is the same. I do not know how this works. Can anyone tell me why?

A explanation from the model and a suggestion from the code so that I can see why I get the same results.


It would help if you showed us the two outputs so we can see for ourselves what you are seeing.

 

Nevertheless, if all you did was change from the value at each time point to the change from baseline, then differences of Least Squares Means won't change. This is simple algebra. You have just subtracted a constant value from the values. Your original differences were

 

(Mean of AVAL at level 1) – (Mean of AVAL at level 2)   <== first formula

 

and now they are

 

((Mean of AVAL at level 1) – baseline) – ((Mean of AVAL at level 2) – baseline) <= second formula

 

Homework assignment for you ... show that the result of the first formula is exactly equal to the result of the second formula using algebra

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

@XixiHaha wrote:

I just change the variable from the value at each time point to the change from baseline. Then I find that the Differences of Least Squares Means is the same. I do not know how this works. Can anyone tell me why?

A explanation from the model and a suggestion from the code so that I can see why I get the same results.


It would help if you showed us the two outputs so we can see for ourselves what you are seeing.

 

Nevertheless, if all you did was change from the value at each time point to the change from baseline, then differences of Least Squares Means won't change. This is simple algebra. You have just subtracted a constant value from the values. Your original differences were

 

(Mean of AVAL at level 1) – (Mean of AVAL at level 2)   <== first formula

 

and now they are

 

((Mean of AVAL at level 1) – baseline) – ((Mean of AVAL at level 2) – baseline) <= second formula

 

Homework assignment for you ... show that the result of the first formula is exactly equal to the result of the second formula using algebra

--
Paige Miller
XixiHaha
Calcite | Level 5
Thanks.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1599 views
  • 1 like
  • 2 in conversation