BookmarkSubscribeRSS Feed
markus24135
Fluorite | Level 6

Hey everyone,

 

I have data that spans from 2005 to 2015 and it is all pharmaceutical claims data.

I am using genmod for a repeated measures analysis. Code is below:

 

proc genmod data=perm.mark243542 descending;

class patient_id2 prevaaobese cohortcat;

model aaobesecat=cohortcat switchedcat prevaaobese*cohortcat/dist=multinomial link=cumlogit;

repeated subject=patient_id2;

estimate "odds of 5 compared to 4 time" cohortcat -1 1 0 0 0 0 /exp;

estimate "odds of 6 compared to 5 time" cohortcat 0 -1 1 0 0 0 /exp;

estimate "odds of 7 compared to 6 time" cohortcat 0 0 -1 1 0 0 /exp;

estimate "odds of 8 compared to 7 time" cohortcat 0 0 0 -1 1 0 /exp;

estimate "odds of 9 compared to 8 time" cohortcat 0 0 0 0 -1 1 /exp;

estimate "odds of 9 compared to 4 time" cohortcat -1 0 0 0 0 1 /exp;

run;

 

Variable definitions:

*cohortcat (categorical variable; 4-9): periods of time within 2005-2015 that we have identified that we want to compare against each other

*aaobesecat (categorical variable;1-3): a list of medications used to treat a specific disease all categorized into 3 categories - 1 = drug does not cause obesity; 2 = drug causes moderate weight gain; 3 drug causes large weight gain; this represents the drug category they are on at the current claim in the data

*prevaaobese (categorical variable;1-3): a list of medications used to treat a specific disease all categorized into 3 categories - 1 = drug does not cause obesity; 2 = drug causes moderate weight gain; 3 drug causes large weight gain; This represents the category of drug they were on in the previous claim [lag(aabobesecat)]

 

****All patients included in this analysis switched medications (not necessarily into a different category of weight gain potential defined by aaobesecat)****

 

The other estimates are just for looking at how the categories change from one time period compared to the last. For instance "Individuals had 5.1% greater odds of being prescribed a large weight gain medication in time period 7 compared to individuals in time period 6".

 

However, I want to be able to say "compared to individuals who switched medications in time period 5, individuals who switched medications in time period 6 who were on a drug that causes a large amount of weight gain had 15% greater odds of switching to a drug that is not known to cause obesity"

 

Given I am using the cumulative logit function and I have descending in the proc statement, I was thinking this could be accomplished by adding:

 

estimate 'switched from most obesogenic in 6 compared to 5(ref)' prevaaobese*cohortcat

cohortcat 0 -1 1 0 0 0

prevaaobese*cohortcat 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 0 0 0 /exp;

 

The attached file shows how I got the 1s and 0s for the interaction term. Please let me know if that is the correct way to do it. If not, can someone please show me how and please don't direct me to a website. I spent all day trying to figure this out online 😕

 

Is that correct or is there a better way to do this?

 

Thank you in advance!!!

8 REPLIES 8
mkeintz
PROC Star

This is likely irrelevant to your question, but why do you have 6 pairs of identical estimate statements?

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
markus24135
Fluorite | Level 6
Good catch, I must have copied the bottom part twice. It should be just one estimate statement comparing one level to the previous one. I'll fix it
SteveDenham
Jade | Level 19

@markus24135  - See the comments by @StatDave  in the thread titled proc genmod Estimate statement help regarding the use of the SLICE option rather than ESTIMATE.

 

SteveDenham

markus24135
Fluorite | Level 6

Hey Steve,

 

Thank you for directing me there. If I was looking at the correct comments, he said that if you are able to avoid using contrast, estimate, or lsmestimate statement because you don't know how to label the coefficients correctly, then avoid it.

 

Instead, he mentioned to try to use slice instead. Proc Genmod does not give me exponentiated results for my model though so I don't even know where I could place that slice statement unless you are saying to use lsmeans with a slice statement like below:

 

lsmeans prevaaobese*cohortcat /sliceby=cohortcat diff;

 

Will that give me exponentiated 95% confidence intervals and odds ratios for level 6 of time compared to level 5 for the large weight gain drugs?

markus24135
Fluorite | Level 6

The way I was able to get: 

prevaaobese*cohortcat 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 0 0 0 /exp;

 

Interaction

Level of Prevaaobese

Level of cohortcat

What this row stands for

Number you would put into the estimate statement in order

Prevaaobese*cohortcat

1

4

When the drug does not make people gain weight and during time period 4

0 (Don’t care about this level)

Prevaaobese*cohortcat

1

5

When the drug does not make people gain weight and during time period 5

0 (Don’t care about this level)

Prevaaobese*cohortcat

1

6

When the drug does not make people gain weight and during time period 6

 0(Don’t care about this level)

Prevaaobese*cohortcat

1

7

When the drug does not make people gain weight and during time period 7

0 (Don’t care about this level)

Prevaaobese*cohortcat

1

8

When the drug does not make people gain weight and during time period 8

0 (Don’t care about this level)

Prevaaobese*cohortcat

1

9

When the drug does not make people gain weight and during time period 9

0 (Don’t care about this level)

Prevaaobese*cohortcat

2

4

When the drug causes moderate weight gain and during time period 4

0 (Don’t care about this level)

Prevaaobese*cohortcat

2

5

When the drug causes moderate weight gain and during time period 5

0 (Don’t care about this level)

Prevaaobese*cohortcat

2

6

When the drug causes moderate weight gain and during time period 6

0 (Don’t care about this level)

Prevaaobese*cohortcat

2

7

When the drug causes moderate weight gain and during time period 7

0 (Don’t care about this level)

Prevaaobese*cohortcat

2

8

When the drug causes moderate weight gain and during time period 8

0 (Don’t care about this level)

Prevaaobese*cohortcat

2

9

When the drug causes moderate weight gain and during time period 9

0 (Don’t care about this level)

Prevaaobese*cohortcat

3

4

When the drug causes large weight gain and during time period 4

0 (Don’t care about this level)

Prevaaobese*cohortcat

3

5

When the drug causes large weight gain and during time period 5

-1 (Yes!!!! I want this level as my reference for comparison!!)

Prevaaobese*cohortcat

3

6

When the drug causes large weight gain and during time period 6

1 (Yes!!!! I want this level as my event!!)

Prevaaobese*cohortcat

3

7

When the drug causes large weight gain and during time period 7

0 (Don’t care about this level)

Prevaaobese*cohortcat

3

8

When the drug causes large weight gain and during time period 8

0 (Don’t care about this level)

Prevaaobese*cohortcat

3

9

When the drug causes large weight gain and during time period 9

0 (Don’t care about this level)

 

Is this the right way to think about it?

SteveDenham
Jade | Level 19

I like it.  Be prepared for me to link other folks to this, as it is a great teaching tool.

 

SteveDenham

markus24135
Fluorite | Level 6

Sounds good, thanks Steve!

 

For a two way interaction using the estimate statement and reference coding, this is the correct way to put this together though right?

 

So if I wanted to compare when the drug causes large weight gain and during time period 6 (the current event category in my example above) to "when the drug causes moderate weight gain and during time period 4" (the 7th row from the top in my example above, which I've pasted below) as the reference category

 

Prevaaobese*cohortcat

2

4

When the drug causes moderate weight gain and during time period 4

0 (Don’t care about this level)

 

it would look like: 

 

prevaaobese*cohortcat 0 0 0 0 0 0 1 0 0 0 0 0 0 -1 0 0 0 0 /exp;

 

And with that comparison, I would be able to say: "individuals who switched medications from a large weight gain medication during period 6 had XX.X% greater odds of switching to a medication that does not cause weight gain compared to individuals who were on a drug that causes moderate weight gain during time period 4."


Does that seem correct?

SteveDenham
Jade | Level 19

It does make sense.

 

One thing that may help in creating multiple comparisons of this kind is the use of non-positional syntax.  It would be well worth your time to work through some of the examples.

 

SteveDenham

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 8 replies
  • 773 views
  • 2 likes
  • 3 in conversation