<?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: PROC FREQ to calculate odds ratio and CI, but no p-value? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503758#M134666</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/110042"&gt;@sharonlee&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found &lt;A href="https://support.sas.com/kb/53/376.html" target="_blank"&gt;SAS&amp;nbsp;Usage Note 53376&lt;/A&gt;&amp;nbsp;helpful for this task and have put together an example showing three different ways to&amp;nbsp;obtain the p-value (for a two-sided Wald test of H&lt;FONT size="1 2 3 4 5 6 7"&gt;0&lt;/FONT&gt;: odds ratio=1 at alpha=0.05, consistent with the corresponding confidence interval):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create test data */

data test;
n11=10; n12=8; n21=58; /* n21=59; */ n22=16;
do _n_=1 to n11; c=1; r=1; output; end;
do _n_=1 to n12; c=1; r=2; output; end;
do _n_=1 to n21; c=2; r=1; output; end;
do _n_=1 to n22; c=2; r=2; output; end;
run;


/* Odds ratio with Wald confidence interval, but without p-value */

ods output relativerisks=rr(where=(statistic=:'O'));

proc freq data=test;
tables c*r / relrisk alpha=0.05;
run;

proc print data=rr;
var _numeric_;
format _numeric_ best16.;
run;


/* Ditto including p-value */

ods select none;
ods select diffs;
ods output diffs=odd;

proc logistic data=test;
class c / param=glm;
model r=c;
lsmeans c / diff oddsratio cl;
run;

ods select all;

proc print data=odd;
var OddsRatio--upperOR Probz;
format _numeric_ best16.;
run;


/* Same using new ORPVALUE option (requires SAS 9.4M3 or later) */

ods select none;
ods select cloddswald;
ods output cloddswald=odc;

proc logistic data=test;
class c / param=glm;
model r=c / clodds=wald orpvalue;
run;

ods select all;

proc print data=odc(drop=unit);
var _numeric_;
format _numeric_ best16.;
run;


/* Alternative: manual calculation */

data orp;
set test(obs=1);
z=probit(0.975);
v=1/n11+1/n12+1/n21+1/n22;
odr=n11*n22/n12/n21;
lcl=odr*exp(-z*sqrt(v));
ucl=odr*exp(z*sqrt(v));
p=1-probchi(log(odr)**2/v,1);
format odr lcl ucl oddsr8.3 p pvalue.;
run;

proc print data=orp(keep=odr--p);
format _all_ best16.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you'll notice, there are minor differences (&amp;lt;1E-7, hence irrelevant, I'd say) between the values computed by PROC LOGISTIC on the one hand and the (slightly more accurate) values computed by PROC FREQ or the last data step on the other hand, maybe due to the model building process (PROC LOGISTIC). By using n21=59 (see first data step) you can switch to a situation where the test is significant.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Oct 2018 16:20:53 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2018-10-12T16:20:53Z</dc:date>
    <item>
      <title>PROC FREQ to calculate odds ratio and CI, but no p-value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503600#M134606</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm using PROC FREQ to calculate an odds ratio. I'm able to get a 95% CI but how can I get the p-value?&lt;/P&gt;&lt;P&gt;I understand that if i look at the CI and if it includes 1, it's not significant, but I'd like to include the actual p-value.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data = test ;&lt;BR /&gt;tables&amp;nbsp;var1*var2 / relrisk alpha=0.05;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 23:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503600#M134606</guid>
      <dc:creator>sharonlee</dc:creator>
      <dc:date>2018-10-11T23:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ to calculate odds ratio and CI, but no p-value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503607#M134608</link>
      <description>&lt;P&gt;Does &lt;A href="https://www.lexjansen.com/wuss/2012/52.pdf" target="_self"&gt;this&lt;/A&gt; help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 00:41:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503607#M134608</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-10-12T00:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ to calculate odds ratio and CI, but no p-value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503610#M134610</link>
      <description>&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;Thanks for sharing this post with me. It seems the Breslow-Day test is computed if there is a third variable. In my case I only have two variables.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 00:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503610#M134610</guid>
      <dc:creator>sharonlee</dc:creator>
      <dc:date>2018-10-12T00:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ to calculate odds ratio and CI, but no p-value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503758#M134666</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/110042"&gt;@sharonlee&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found &lt;A href="https://support.sas.com/kb/53/376.html" target="_blank"&gt;SAS&amp;nbsp;Usage Note 53376&lt;/A&gt;&amp;nbsp;helpful for this task and have put together an example showing three different ways to&amp;nbsp;obtain the p-value (for a two-sided Wald test of H&lt;FONT size="1 2 3 4 5 6 7"&gt;0&lt;/FONT&gt;: odds ratio=1 at alpha=0.05, consistent with the corresponding confidence interval):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create test data */

data test;
n11=10; n12=8; n21=58; /* n21=59; */ n22=16;
do _n_=1 to n11; c=1; r=1; output; end;
do _n_=1 to n12; c=1; r=2; output; end;
do _n_=1 to n21; c=2; r=1; output; end;
do _n_=1 to n22; c=2; r=2; output; end;
run;


/* Odds ratio with Wald confidence interval, but without p-value */

ods output relativerisks=rr(where=(statistic=:'O'));

proc freq data=test;
tables c*r / relrisk alpha=0.05;
run;

proc print data=rr;
var _numeric_;
format _numeric_ best16.;
run;


/* Ditto including p-value */

ods select none;
ods select diffs;
ods output diffs=odd;

proc logistic data=test;
class c / param=glm;
model r=c;
lsmeans c / diff oddsratio cl;
run;

ods select all;

proc print data=odd;
var OddsRatio--upperOR Probz;
format _numeric_ best16.;
run;


/* Same using new ORPVALUE option (requires SAS 9.4M3 or later) */

ods select none;
ods select cloddswald;
ods output cloddswald=odc;

proc logistic data=test;
class c / param=glm;
model r=c / clodds=wald orpvalue;
run;

ods select all;

proc print data=odc(drop=unit);
var _numeric_;
format _numeric_ best16.;
run;


/* Alternative: manual calculation */

data orp;
set test(obs=1);
z=probit(0.975);
v=1/n11+1/n12+1/n21+1/n22;
odr=n11*n22/n12/n21;
lcl=odr*exp(-z*sqrt(v));
ucl=odr*exp(z*sqrt(v));
p=1-probchi(log(odr)**2/v,1);
format odr lcl ucl oddsr8.3 p pvalue.;
run;

proc print data=orp(keep=odr--p);
format _all_ best16.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you'll notice, there are minor differences (&amp;lt;1E-7, hence irrelevant, I'd say) between the values computed by PROC LOGISTIC on the one hand and the (slightly more accurate) values computed by PROC FREQ or the last data step on the other hand, maybe due to the model building process (PROC LOGISTIC). By using n21=59 (see first data step) you can switch to a situation where the test is significant.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 16:20:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503758#M134666</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-12T16:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ to calculate odds ratio and CI, but no p-value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503775#M134673</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/110042"&gt;@sharonlee&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm using PROC FREQ to calculate an odds ratio. I'm able to get a 95% CI but how can I get the p-value?&lt;/P&gt;
&lt;P&gt;I understand that if i look at the CI and if it includes 1, it's not significant, but I'd like to include the actual p-value.&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;p_values only exist in relationship to a test. I don't see a test requested. As an example this an equivalence test&lt;/P&gt;
&lt;PRE&gt;proc freq data = test ;
tables var1*var2 / relrisk (method=wald equiv) alpha=0.05;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Oct 2018 16:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503775#M134673</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-12T16:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ to calculate odds ratio and CI, but no p-value?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503952#M134781</link>
      <description>&lt;P&gt;This was very helpful!!!&amp;nbsp; Thank you for taking the time to respond to my question. It saved me lots of time and energy.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 23:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-to-calculate-odds-ratio-and-CI-but-no-p-value/m-p/503952#M134781</guid>
      <dc:creator>sharonlee</dc:creator>
      <dc:date>2018-10-12T23:53:07Z</dc:date>
    </item>
  </channel>
</rss>

