<?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 calculate prevalence ratio with a binary outcome in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-prevalence-ratio-with-a-binary-outcome/m-p/931404#M366441</link>
    <description>&lt;P&gt;It is better to post it at STAT Forum:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/Statistical-Procedures/bd-p/statistical_procedures" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/Statistical-Procedures/bd-p/statistical_procedures&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and calling&amp;nbsp; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633"&gt;@StatDave&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 09 Jun 2024 02:47:26 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2024-06-09T02:47:26Z</dc:date>
    <item>
      <title>How to calculate prevalence ratio with a binary outcome</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-prevalence-ratio-with-a-binary-outcome/m-p/931396#M366436</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to calculate prevalence ratios in SAS with a binary outcome having many covariates.&lt;/P&gt;&lt;P&gt;Data look like this roughly:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input m$ a$ b$ c @@;&lt;BR /&gt;datalines;&lt;BR /&gt;0 1 0 34&amp;nbsp;1 2 0 56&lt;BR /&gt;1 3 1 54&amp;nbsp;0 2 1 23&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;m is a binary outcome (0 or 1), a (1, 2, or 3) and b (0 or 1) is categorical exposures, and c is continuous one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At first, I calculated odds ratios very easily as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc logistic data=have descending;&lt;BR /&gt;class a (ref="1")&amp;nbsp;b (ref="1")&amp;nbsp;&amp;nbsp;/ param=glm;&lt;BR /&gt;model m(event="1") = a b c;&lt;BR /&gt;lsmeans a&amp;nbsp; b c/ e ilink;&lt;BR /&gt;ods output coef=coeffs;&lt;BR /&gt;store out=ques;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I tried calculate prevalence ratios with a macro:&lt;/P&gt;&lt;P&gt;%nlmeans(instore=ques, coef=coeffs, link=logit, options=ratio, title=Relative Risk)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But there was a warning message:&amp;nbsp;&lt;/P&gt;&lt;P&gt;The final Hessian matrix is not positive definite, and therefore the estimated covariance matrix is not full&lt;BR /&gt;rank and may be unreliable. The variance of some parameter estimates is zero or some parameters are&lt;BR /&gt;linearly related to other parameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried it using PROC GENMOD&lt;/P&gt;&lt;P&gt;proc genmod data=have descending;&lt;BR /&gt;class a (ref="1")&amp;nbsp;b (ref="1") ;&lt;BR /&gt;model m = a b c / dist=bin link=log type3 corrb;&lt;BR /&gt;estimate "RR for a1" a&amp;nbsp; 1 -1 0&amp;nbsp; /exp;&lt;/P&gt;&lt;P&gt;estimate "RR for a2" a 1 0 -1&amp;nbsp; /exp;&lt;BR /&gt;estimate "RR for b"b 1 -1&amp;nbsp; /exp;&lt;BR /&gt;estimate "RR for c" c 1&amp;nbsp; /exp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I also got a warning message like this:&lt;/P&gt;&lt;P&gt;The relative Hessian convergence criterion of 0.0199906038 is greater than the limit of 0.0001. The&lt;BR /&gt;convergence is questionable.&lt;BR /&gt;WARNING: The procedure is continuing but the validity of the model fit is questionable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In addition, the direction of estimates is totally different from the results out of PROC LOGISTIC.&lt;/P&gt;&lt;P&gt;For example, while I got the estimate 0.55 and 0.32 for each group of variable "a" from logistic regression, PROC GENMOD showed 1.44 and 3.56, respectively.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I tried dist=poisson instead of bin, but I am not sure if this is correct.&lt;/P&gt;&lt;P&gt;I have reviewed this note (&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;) but I guess this was calculated from count data. Mine has a binary outcome.&lt;/P&gt;&lt;P&gt;I've also heard that I could try calculate adjusted prevalence or marginal prevalence. But I have no idea how to calculate this in SAS.&lt;/P&gt;&lt;P&gt;Please help me out to estimate prevalence ratios correctly in this situation. Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2024 23:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-prevalence-ratio-with-a-binary-outcome/m-p/931396#M366436</guid>
      <dc:creator>nexterd</dc:creator>
      <dc:date>2024-06-08T23:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate prevalence ratio with a binary outcome</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-prevalence-ratio-with-a-binary-outcome/m-p/931403#M366440</link>
      <description>&lt;P&gt;"&lt;/P&gt;
&lt;P&gt;For example, while I got the estimate 0.55 and 0.32 for each group of variable "a" from logistic regression, PROC GENMOD showed 1.44 and 3.56, respectively.&lt;/P&gt;
&lt;P&gt;"&lt;/P&gt;
&lt;P&gt;That was supposed to be . PROC LOGISTIC model Y=log(p/1-p), but PROC GENMOD model Y=p . therefore the estimated coefficience is totally different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you should put C variable in WEIGHT/FREQ statement ,not as a X variable ,like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod data=have descending;
class a (ref="1") b (ref="1") ;
model m = a b / dist=bin link=log type3 corrb;
weight c;

estimate "RR for a1" a  1 -1 0  /exp;
estimate "RR for a2" a 1 0 -1  /exp;
estimate "RR for b"  b 1 -1  /exp;

lsmeans a / diff exp cl;
lsmeans b / diff exp cl;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod data=have descending;
class  a (ref="1")  b (ref="1") ;
model m = a b / dist=bin link=log type3 corrb;
freq c;
lsmeans a / diff exp cl;
lsmeans b / diff exp cl;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And since your X variable are all category variable, you also could try PROC FREQ like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq order=data data=have;
        tables a*b*m / cmh;
        weight c;
        run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Further more, about your WARNING message, I think it is due to your data is too sparse.&lt;/P&gt;
&lt;P&gt;for example:&amp;nbsp; when a=1 ,m only have 0 ; a=3 ,m only have 1.&lt;/P&gt;
&lt;P&gt;a.k.a you need more data to get what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jun 2024 02:34:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-prevalence-ratio-with-a-binary-outcome/m-p/931403#M366440</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-06-09T02:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate prevalence ratio with a binary outcome</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-prevalence-ratio-with-a-binary-outcome/m-p/931404#M366441</link>
      <description>&lt;P&gt;It is better to post it at STAT Forum:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/Statistical-Procedures/bd-p/statistical_procedures" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/Statistical-Procedures/bd-p/statistical_procedures&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and calling&amp;nbsp; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633"&gt;@StatDave&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jun 2024 02:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-prevalence-ratio-with-a-binary-outcome/m-p/931404#M366441</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-06-09T02:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate prevalence ratio with a binary outcome</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-prevalence-ratio-with-a-binary-outcome/m-p/931413#M366443</link>
      <description>Many thanks! I also asked this at STAT Forum.</description>
      <pubDate>Sun, 09 Jun 2024 05:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-prevalence-ratio-with-a-binary-outcome/m-p/931413#M366443</guid>
      <dc:creator>nexterd</dc:creator>
      <dc:date>2024-06-09T05:55:42Z</dc:date>
    </item>
  </channel>
</rss>

