BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mikemangini
Obsidian | Level 7

I would like to use Proc Glimmix to compare the difference in hospital effects between each hospital in my study and the average.


So basically I want to look at each Hospital (42 in total) and compare them with the average. Using the SAS documentation and a couple of online searches I have been able to get my code (simplified) to what is pasted below.


This gives me the OR and CL for one hospital. What I am uncertain of is how to be sure which hospital I am analyzing. In the example below, which hospital is HOSPITAL 41? And if I change it to 40, which is 40? How can I get SAS to include the Hospital ID in the output so I am absolutely sure which hospital is being reported on? Alternatively, how could I set this approach up to step through each Hospital and give me my results?


Code:

proc glimmix data = Analysis_vaginal_final;

class HOSPITAL;

model Y(event="1") = X    / dist=BINARY link=LOGIT ddfm=BW solution;

random HOSPITAL / solution;

   estimate 'HOSPITAL1 vs Avg' | HOSPITAL

   41 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

        -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

        -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

        -1 -1 -1 -1 -1 / divisor=42 df=41 OR CL;

run;

Desired Output:

HOSPITALRelative RiskP-Value
011.010.27
020.750.81
031.550.04
1 ACCEPTED SOLUTION

Accepted Solutions
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

Hospitals are referenced by position (sorted by number or letter). A coefficient for each hospital in order. So your code is (almost) giving the difference between the first hospital and the average of the rest. However, your divisor should be 41. For the second hospital, you would write:

estimate '...' |  hospital -1 41 -1 -1 -1 .....;

where the dots are for the remaining stuff, or remaining -1s. An estimate statement for each hospital.

View solution in original post

5 REPLIES 5
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

Hospitals are referenced by position (sorted by number or letter). A coefficient for each hospital in order. So your code is (almost) giving the difference between the first hospital and the average of the rest. However, your divisor should be 41. For the second hospital, you would write:

estimate '...' |  hospital -1 41 -1 -1 -1 .....;

where the dots are for the remaining stuff, or remaining -1s. An estimate statement for each hospital.

mikemangini
Obsidian | Level 7

Thank you for your reply. This is very helpful. So the order is determined by how the input data set is already pre-sorted? So assuming my IDs are {1,2,...42}, I can step through sequentially?

So the next two iterations in order to get the ratios for hospital 2 and hospital 3 would be:

...

   estimate 'Hospital2 vs Avg' | PRV_NUM

    -1 41 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

      -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

      -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

   -1 -1 -1 -1 -1 / divisor=41 df=41 OR CL;

...

estimate 'Hospital3 vs Avg' | PRV_NUM

    -1 -1 41 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

      -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

      -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

   -1 -1 -1 -1 -1 / divisor=41 df=41 OR CL;

I am fine with doing this 42 times, however, any way in PROC GLIMMIX to streamline this that you are aware of?

lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

Not sorted by data order. It will be sorted internally (1, 2, 3, etc.). Look at the SOlution table for hospital to see the order that GLIMMIX is using.

There is no streamlining. One can write a macro to do this, but you need to know how to write simple macros and inserting them within procedures. There are examples in SAS for Mixed Models, 2nd edition. You can put everything in one big estimate statement, separating by commas, but you still have to write out all the coefficients.

mikemangini
Obsidian | Level 7

Great, thank you so much for your help. I really appreciate it.

SteveDenham
Jade | Level 19

Hopefully future versions of SAS/STAT will implement something like the DIFF=ANOM from the LSMEANS statement, but for the BLUPs like you are doing.  That would be pretty useful, especially in the analysis of breeding records.

Steve Denham

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5 replies
  • 1600 views
  • 3 likes
  • 3 in conversation