<?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 oddsratio for multiple interaction terms in proc logistic? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/823101#M40751</link>
    <description>I am looking at the interaction between location (urban vs rural) and race. My hypothesis is that location moderates the relationship between race and the outcome (availability of addiction physicians). But as I mentioned previously, this is an area level data, so I have counts and % of whites, blacks, hispanics. They are 3 separate variables and three interaction need to be tested separately, but my issue is that SAS is giving OR for all three races.</description>
    <pubDate>Wed, 13 Jul 2022 13:49:40 GMT</pubDate>
    <dc:creator>sas_sad</dc:creator>
    <dc:date>2022-07-13T13:49:40Z</dc:date>
    <item>
      <title>How to get oddsratio for multiple interaction terms in proc logistic?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/819234#M40505</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to get OR for 3 interaction term but SAS is not giving me the output that I am looking for.&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc logistic data=bp;
class location(ref='1')
mhi_q (ref='4') 
lesshs_q (ref='4') 
nhwmed_p (ref='2') 
nhbmed_p (ref='2') 
hispmed_p (ref='2') 
/param=ref;
model bpyn(event='1') = location mhi_q lesshs_q  nhwmed_p nhbmed_p hispmed_p unemprate HI_rate location*nhwmed_p location*nhbmed_p location*hispmed_p;
oddsratio location/at(nhbmed_p='1' '2') diff=ref;
oddsratio location/at (hispmed_p='1' '2') diff=ref;
oddsratio location/at (nhwmed_p= '1' '2') diff=ref;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="OR.PNG" style="width: 521px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72471i87D14DF4BA839609/image-dimensions/521x234?v=v2" width="521" height="234" role="button" title="OR.PNG" alt="OR.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This output gives me OR for all 3 race/ethnicity (Black, White, Hispanic) at once for location (rural=0, urban=1). Race/ethnicity is coded as 1 and 2, so all&amp;nbsp; three of them are separate variables. What output I need is like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Location 0 vs 1 at NHWMed_P=1&amp;nbsp;NHWMed_P=2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Location 0 vs 1 at NHBMed_P=1&amp;nbsp;NHBMed_P=2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Location 0 vs 1 at HispMed_P=1 HispMed_P=2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried changing the codes multiple times, but nothing gives this output. Please help me!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 00:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/819234#M40505</guid>
      <dc:creator>sas_sad</dc:creator>
      <dc:date>2022-06-21T00:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to get oddsratio for multiple interaction terms in proc logistic?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/819237#M40506</link>
      <description>&lt;P&gt;I assume what you want is the odds ratio of location for each race. Create just a single, three-level variable for race, rather than three separate variables, then you need only include one interaction for location*race. This should do it.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc logistic data=bp;
class location(ref='1') mhi_q (ref='4')  lesshs_q (ref='4')  race / param=ref;
model bpyn(event='1') = location mhi_q lesshs_q  race unemprate HI_rate location*race;
oddsratio location;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jun 2022 01:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/819237#M40506</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2022-06-21T01:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to get oddsratio for multiple interaction terms in proc logistic?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/819238#M40507</link>
      <description>This is an area level data, specifically zip code, so what I have is % or counts of Whites, Blacks, Hispanic in each zip code, that is why they are separate variables. So, I can't create a single variable for race.</description>
      <pubDate>Tue, 21 Jun 2022 01:49:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/819238#M40507</guid>
      <dc:creator>sas_sad</dc:creator>
      <dc:date>2022-06-21T01:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get oddsratio for multiple interaction terms in proc logistic?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/819239#M40508</link>
      <description>&lt;P&gt;Then you need to explain much more about the data - particularly these race variables - and a clearer explanation of what precisely you want to estimate.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 02:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/819239#M40508</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2022-06-21T02:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to get oddsratio for multiple interaction terms in proc logistic?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/823101#M40751</link>
      <description>I am looking at the interaction between location (urban vs rural) and race. My hypothesis is that location moderates the relationship between race and the outcome (availability of addiction physicians). But as I mentioned previously, this is an area level data, so I have counts and % of whites, blacks, hispanics. They are 3 separate variables and three interaction need to be tested separately, but my issue is that SAS is giving OR for all three races.</description>
      <pubDate>Wed, 13 Jul 2022 13:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/823101#M40751</guid>
      <dc:creator>sas_sad</dc:creator>
      <dc:date>2022-07-13T13:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to get oddsratio for multiple interaction terms in proc logistic?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/823197#M40780</link>
      <description>&lt;P&gt;If I understand your data, each observation is associated with one of two locations and has three variables containing the proportions of the three races (and presumably sum to one). If so, then the following might give you what you want. The trick here is to create a categorical race variable in the model such that it has three levels and therefore three columns in the design matrix, but instead of those columns containing either a 1 or 0 to indicate that the observation belongs entirely to one race, they instead contain the proportions. This can be done using the EFFECT statement to create a collection type of variable. The result is a model with the expected degrees of freedom for the model effects: 1 for location, 2 for race, and 2 for the interaction. You can then use ESTIMATE statements to estimate the log odds for the locations in a given race and the odds ratio (exponentiated difference in log odds) of the locations in that race. For example, assuming you have three race level variables (w, b, h) containing the proportions of each race, the following fits the model and computes the log odds and odds ratio for race=w. The design data set that is created by the OUTDESIGN= option lets you examine the design matrix used to fit the model.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc logistic data=bp outdesign=od; 
class location / param=glm; 
effect race=collection(w b h/details);
model y=loc|race;
estimate 'loc 0 race w' intercept 1 loc 1 0 race 1 0 0 loc*race 1 0  0 0  0 0 / ilink;
estimate 'loc 1 race w' intercept 1 loc 0 1 race 1 0 0 loc*race 0 1  0 0  0 0 / ilink;
estimate 'OR loc 0 vs 1 race w' loc 1 -1 loc*race 1 -1  0 0  0 0 / exp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jul 2022 18:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/823197#M40780</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2022-07-13T18:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to get oddsratio for multiple interaction terms in proc logistic?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/823246#M40788</link>
      <description>&lt;P&gt;...but you can also use the ODDSRATIO statement to estimate the odds ratio for each pure race level and that is easier than the ESTIMATE statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   oddsratio loc / at(w=1 b=0 h=0);
   oddsratio loc / at(w=0 b=1 h=0);
   oddsratio loc / at(w=0 b=0 h=1);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jul 2022 03:41:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-oddsratio-for-multiple-interaction-terms-in-proc/m-p/823246#M40788</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2022-07-14T03:41:28Z</dc:date>
    </item>
  </channel>
</rss>

