Obsidian | Level 7

## proc glm : difference in dependent variable adjusted for covariates

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  ;
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
SAS Super FREQ

## Re: proc glm : difference in dependent variable adjusted for covariates

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.

## Re: proc glm : difference in dependent variable adjusted for covariates

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

SAS Super FREQ

## Re: proc glm : difference in dependent variable adjusted for covariates

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  ;
lsmeans cate  /pdiff 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 ;
run;
``````

Discussion stats
• 3 replies
• 1033 views
• 5 likes
• 4 in conversation