BookmarkSubscribeRSS Feed
riyaaora275
Obsidian | Level 7

I have a dependent variable - y 

and independent vars - 

cate has two levels - A and B 

gender has two levels Male and female  

adh has two levels - 0 and 1 

proc glm data=change  ;
class cate gender  ;
model y= class sex age adh adh*class /solution;
lsmeans cate  /pdiff e;
lsmeans cate*adh / pdiff e; estimate 'A vs B' cate 1 -1/e ; run;

want :

1. Difference in y between class a and class b ( adjusted for sex and age adh )

2. Difference in y between class a and class b split by adh ( adjusted for sex and age) 

 

which statement would give me these results ?

1. lsmeans ? 

2. estimate statement ? 

3. solution option - parameter estimates ?

 

 

3 REPLIES 3
StatsMan
SAS Super FREQ

The LSMEANS approach with PDIFF should give you what you are looking for. The results of the /E option on the LSMEANS statement shows how the differences are adjusted over the other factors in the model. The usual statistical advice applies here. If you have factors A, B, and A*B in the model and if A*B is significant, then differences in the levels of the main effects A and B are usually of little interest, since those differences in the levels of A will depend on what level of B is used. Looking at slices of the interaction can be a useful approach then.

SteveDenham
Jade | Level 19

For this to run, you will have to replace 'class' with 'cate' in your MODEL statement.  You should also add 'adh' to your CLASS statement.

 

Your first LSMEANS statement will give the difference between cate=A and cate=B, at the average age, and marginally over sex and adh.

 

To get the comparison between cate=A and cate=B for each level of adh, simply examine the output from the second LSMEANS statement.

 

Question 1: The LSMEANS statements.

Question 2: The ESTIMATE statement

Question 3: The MODEL statement.

 

These answers should be obvious from the code.

 

SteveDenham

 

jiltao
SAS Super FREQ

You would need to change your CLASS and MODEL statements so they would make your program run properly.

You can use the LSMEANS statement to get the comparisons you want --

 

proc glm data=change  ;
class cate gender adh  ;
model y= cate sex age adh adh*cate /solution;
lsmeans cate  /pdiff e;
lsmeans cate*adh / slice=adh e;
store glmout;
run;

 

The second LSMEANS statement with the SLICE= option provides the test for CATE for each level of ADH. It does not produce the magnitude of the difference between Cate A and B for each level of ADH. If you also want to have the magnitude of the difference, you might use the SLICE statement in PROC PLM. The STORE statement in PROC GLM makes the next code possible --

 

proc plm restore=glmout ;
   slice cate*adh / sliceby=adh diff;
run;

 

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 1008 views
  • 5 likes
  • 4 in conversation