<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to get categorical variables RR estimates in PROC GENMOD in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-categorical-variables-RR-estimates-in-PROC-GENMOD/m-p/761928#M37203</link>
    <description>&lt;P&gt;That error is very common with the log binomial model and occurs because the log link doesn't insure that predicted values are between 0 and 1 as required by the binomial distribution&amp;nbsp; That is why I suggest avoiding this model. This error is discussed in some detail in &lt;A href="http://support.sas.com/kb/23003" target="_self"&gt;the note&lt;/A&gt; on relative risks that you referred to earlier. See the section on the log binomial model.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Aug 2021 21:43:50 GMT</pubDate>
    <dc:creator>StatDave</dc:creator>
    <dc:date>2021-08-16T21:43:50Z</dc:date>
    <item>
      <title>How to get categorical variables RR estimates in PROC GENMOD</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-categorical-variables-RR-estimates-in-PROC-GENMOD/m-p/760775#M37094</link>
      <description>&lt;P&gt;Hello everyone, I have a question about how to get categorical variables RR estimates in PROC GENMOD.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a PROC GENMOD tutorial from this link: &lt;A href="https://stats.idre.ucla.edu/sas/faq/how-can-i-estimate-relative-risk-in-sas-using-proc-genmod-for-common-outcomes-in-cohort-studies/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/faq/how-can-i-estimate-relative-risk-in-sas-using-proc-genmod-for-common-outcomes-in-cohort-studies/ &lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I used is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the&amp;nbsp;above code, I have this output.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-08-10 at 5.36.36 PM.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62460i5EF46F0A69937D34/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2021-08-10 at 5.36.36 PM.png" alt="Screen Shot 2021-08-10 at 5.36.36 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Although you can see the estimates don't show for different categories of x and z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I searched for other solutions. Then I found this solution:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Statistical-Procedures/RR-estimates-using-proc-Genmod-for-categorical-variables/m-p/549129#M27406" target="_blank"&gt;https://communities.sas.com/t5/Statistical-Procedures/RR-estimates-using-proc-Genmod-for-categorical-variables/m-p/549129#M27406&lt;/A&gt;&lt;/P&gt;&lt;P&gt;link to this website:&amp;nbsp;&lt;A href="https://support.sas.com/kb/23/003.html" target="_blank"&gt;https://support.sas.com/kb/23/003.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I tried to use LSMEANS, the below code is I modified to get&amp;nbsp;categorical variables RR estimates.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;

&lt;FONT color="#FF0000"&gt;lsmeans  x z / diff exp cl; /*I only added this line comparing to the code above*/&lt;/FONT&gt;

estimate 'Beta_x' x 1 -1/exp;
estimate 'Beta_y' y 1 -1/exp;
estimate 'Beta_z' z 1 -1/exp;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-08-10 at 5.43.05 PM.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62461iB3E272297327EAA2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2021-08-10 at 5.43.05 PM.png" alt="Screen Shot 2021-08-10 at 5.43.05 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am not sure if I used LSMEANS in the right way.&lt;/P&gt;&lt;P&gt;Also, I wanted to ask what "1 -1" stands for in "estimate 'Beta_x &lt;FONT color="#FF0000"&gt;1 - 1&lt;/FONT&gt;/ 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!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your help!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 22:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-categorical-variables-RR-estimates-in-PROC-GENMOD/m-p/760775#M37094</guid>
      <dc:creator>N0o9r5a</dc:creator>
      <dc:date>2021-08-10T22:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to get categorical variables RR estimates in PROC GENMOD</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-categorical-variables-RR-estimates-in-PROC-GENMOD/m-p/760802#M37095</link>
      <description>&lt;P&gt;The coefficients in the ESTIMATE (or CONTRAST) statement create a vector of values, appropriate for the quantity that you want to estimate or test, that multiplies the vector of model parameter estimates. As such, there should be exactly as many coefficients for an effect in the model (like your X, Y, or Z) as there are parameter estimates in the parameter estimates table. As you can see, there are 4, 1, and 4 parameter estimates for X, Y, and Z respectively, so your two coefficients in each case are not correct for any of them. If you really want to understand this, then see &lt;A href="http://support.sas.com/kb/24447" target="_self"&gt;this note&lt;/A&gt;. However, as stated there, the ESTIMATE and CONTRAST statements should be avoided when simpler statements can be used that don't require you to properly determine coefficients - the LSMEANS statement being one such. In your case, I strongly advise that you to avoid the log-binomial model that you are attempting. Instead, fit a simple logistic model using PROC LOGISTIC and then use the NLMeans macro (as shown in Note 23003 that you referred to) to estimate and test the relative risks. You will need to download updated versions of the NLMeans and NLEST macros in order to use the NULL= option if desired. If you are determined to use the log-binomial model then, as also shown in Note 23003, you need to remove the ESTIMATE statements and specify PARAM=GLM, not PARAM=REF (or just omit the PARAM= option), in the CLASS statement(s) as suggested by the Warnings in order to get the relative risk estimates from the LSMEANS statement.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2021 03:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-categorical-variables-RR-estimates-in-PROC-GENMOD/m-p/760802#M37095</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2021-08-11T03:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to get categorical variables RR estimates in PROC GENMOD</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-categorical-variables-RR-estimates-in-PROC-GENMOD/m-p/761925#M37202</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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"&amp;nbsp;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?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 21:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-categorical-variables-RR-estimates-in-PROC-GENMOD/m-p/761925#M37202</guid>
      <dc:creator>N0o9r5a</dc:creator>
      <dc:date>2021-08-16T21:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to get categorical variables RR estimates in PROC GENMOD</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-categorical-variables-RR-estimates-in-PROC-GENMOD/m-p/761928#M37203</link>
      <description>&lt;P&gt;That error is very common with the log binomial model and occurs because the log link doesn't insure that predicted values are between 0 and 1 as required by the binomial distribution&amp;nbsp; That is why I suggest avoiding this model. This error is discussed in some detail in &lt;A href="http://support.sas.com/kb/23003" target="_self"&gt;the note&lt;/A&gt; on relative risks that you referred to earlier. See the section on the log binomial model.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 21:43:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-categorical-variables-RR-estimates-in-PROC-GENMOD/m-p/761928#M37203</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2021-08-16T21:43:50Z</dc:date>
    </item>
  </channel>
</rss>

