Programming the statistical procedures from SAS

PROC GLIMMIX Profiling Using Divisor List

Accepted Solution Solved
Reply
Contributor
Posts: 34
Accepted Solution

PROC GLIMMIX Profiling Using Divisor List

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

Accepted Solutions
Solution
‎04-28-2015 10:39 AM
Valued Guide
Valued Guide
Posts: 684

Re: PROC GLIMMIX Profiling Using Divisor List

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


All Replies
Solution
‎04-28-2015 10:39 AM
Valued Guide
Valued Guide
Posts: 684

Re: PROC GLIMMIX Profiling Using Divisor List

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.

Contributor
Posts: 34

Re: PROC GLIMMIX Profiling Using Divisor List

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?

Valued Guide
Valued Guide
Posts: 684

Re: PROC GLIMMIX Profiling Using Divisor List

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.

Contributor
Posts: 34

Re: PROC GLIMMIX Profiling Using Divisor List

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

Respected Advisor
Posts: 2,655

Re: PROC GLIMMIX Profiling Using Divisor List

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 424 views
  • 3 likes
  • 3 in conversation