Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Re: How to get categorical variables RR estimates in PROC GENMOD

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 08-10-2021 06:51 PM
(3190 views)

Hello everyone, I have a question about how to get categorical variables RR estimates in PROC GENMOD.

My outcome is a binomial variable (death), which 1= event happened, 0=event didn't happen. I listed 3 variables (x, y, z) as exposures that I am looking for to get their RR estimate in the PROC GENMOD procedure. All 3 variables are categorical, x has 5 categories, y has 2 categories, z has 5 categories. There is no missing value among those 4 variables.

I found a PROC GENMOD tutorial from this link: https://stats.idre.ucla.edu/sas/faq/how-can-i-estimate-relative-risk-in-sas-using-proc-genmod-for-co...

The code I used is:

```
proc genmod data = test;
class x (ref="1")/param=ref;
class y (ref="1")/param=ref;
class z (ref="1")/param=ref;
model death (event="1") = x y z/ dist=binomial link=log;
estimate 'Beta_x' x 1 -1/exp;
estimate 'Beta_y' y 1 -1/exp;
estimate 'Beta_z' z 1 -1/exp;
run;
```

With the above code, I have this output.

Although you can see the estimates don't show for different categories of x and z.

I searched for other solutions. Then I found this solution: https://communities.sas.com/t5/Statistical-Procedures/RR-estimates-using-proc-Genmod-for-categorical...

link to this website: https://support.sas.com/kb/23/003.html

So I tried to use LSMEANS, the below code is I modified to get categorical variables RR estimates.

```
proc genmod data = test;
class x (ref="1")/param=ref;
class y (ref="1")/param=ref;
class z (ref="1")/param=ref;
model death (event="1") = x y z/ dist=binomial link=log;
lsmeans x z / diff exp cl; /*I only added this line comparing to the code above*/
estimate 'Beta_x' x 1 -1/exp;
estimate 'Beta_y' y 1 -1/exp;
estimate 'Beta_z' z 1 -1/exp;
run;
```

Although nothing new results showed up with this code, SAS generated the same results as the first screenshot I attached. Also, with the following Note and Warning:

I am not sure if I used LSMEANS in the right way.

Also, I wanted to ask what "1 -1" stands for in "estimate 'Beta_x 1 - 1/ exp"? I have seen some tutorial shows "1 -1" or "1" or "0 1 -1", but I don't really understand the function of it. If there are some tutorials I should know before doing this code, I would love to know about them!

I appreciate your help!

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hello,

Thank you for the solution! It was a huge help! I haven't learned how to use the macro, so I guess sticking with the proc genmod is more straightforward to me.

Although I have another weird situation. The code works fine after I did the changes you suggested, but once I add more than 6 or 7 variables in the same model, an error shows "The mean parameter is either invalid or at a limit of its range for some observations" and couldn't show the correct results. At first, I thought because of the limitation of certain categories, but the same error shows even there are more than 2000 samples in that category. Do you happen to know why would this happen?

I appreciate your help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

**SAS Innovate 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

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.