<?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: Reversing a Pvalue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901894#M356399</link>
    <description>&lt;P&gt;Rick, &lt;BR /&gt;You understand the setup of my datalines correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea is to find the minimum number of events that need to change in order to reverse the pvalue from &amp;gt;0.05 to &amp;lt;0.05.&lt;/P&gt;
&lt;P&gt;It looks like the code you provided shows that. Is it possible, instead of on a graph, to show a table of the changes? Something like below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;# of events changed&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pvalue(hypothetical)&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.061&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.053&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.047&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Nov 2023 15:16:49 GMT</pubDate>
    <dc:creator>GS2</dc:creator>
    <dc:date>2023-11-07T15:16:49Z</dc:date>
    <item>
      <title>Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901101#M356116</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using SAS 9.4, I want to calculate how many events would have to change from positive to negative to change a pvalue in a binary outcome. So, I have a binary outcome, disease, that is statistically significant (0.04); I want to know how many of the disease-yes would have to change to disease-no in order for the pvalue to become non-significant (0.05).&amp;nbsp;Likewise, I would calculate the reverse of this where the pvalue is not significant and calculate how many disease-no would have to change to disease-yes to become significant.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone have an efficient way in SAS to perform this? Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 16:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901101#M356116</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2023-11-01T16:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901102#M356117</link>
      <description>&lt;P&gt;Without knowing the exact statistical test you have performed, I can't be specific.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you could certainly program a loop in a data step to increase/decrease the number of no responses and/or increase/decrease the number of yes responses to see what effect it has on the p-value.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 17:08:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901102#M356117</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-01T17:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901121#M356122</link>
      <description>&lt;P&gt;The test is a Chi Square or Fisher's exact.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you have an example of what a loop like that would look like? Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 17:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901121#M356122</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2023-11-01T17:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901137#M356131</link>
      <description>&lt;P&gt;Is this for a 2x2 table? For example, Disease (No/Yes) as a response to clinical ARM (Control/Experimental)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, Fisher's exact test enumerates all tables that have the observed row sums and column sums while fixing the sample size. Thus, there are three constraints for the four cells in the table. You can easily enumerate all tables by considering 0, 1, ..., n for the first cell and then using the constraints to fill in the other cells.&lt;/P&gt;
&lt;P&gt;The probability for these tables follows a hypergeometric distribution, so you can compute the probability of each case.&amp;nbsp; the parameters of the hypergeometric distribution are&lt;/P&gt;
&lt;P&gt;N = sample size&lt;BR /&gt;R = sum of first row&lt;BR /&gt;n = sum of first column&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A discussion and example are provided in the article, &lt;A href="https://blogs.sas.com/content/iml/2015/10/14/sim-2x2-model.html" target="_self"&gt;"Models and simulation for 2x2 contingency tables."&lt;/A&gt;&amp;nbsp;In the article, I generate random tables, but it is straightforward to modify the program to enumerate them.&amp;nbsp;(You can &lt;A href="https://blogs.sas.com/content/iml/2015/10/28/simulation-exact-tables.html" target="_self"&gt;extend this idea to RxC tables&lt;/A&gt;, but then Monte Carlo simulation is preferable to trying to enumerate all possibilities.)&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 18:14:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901137#M356131</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-01T18:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901139#M356133</link>
      <description>&lt;P&gt;More specific information is needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean a one-way table chi-squared test? Which is really a binomial test of proportions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean a two-way table chi-squared test?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean something else?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 18:16:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901139#M356133</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-01T18:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901143#M356137</link>
      <description>&lt;P&gt;Yes, this is a 2x2 table. Disease is a binary and I have a binary grouping variable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 18:30:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901143#M356137</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2023-11-01T18:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901144#M356138</link>
      <description>Do you have any recommendations if I am not able to use proc iml?</description>
      <pubDate>Wed, 01 Nov 2023 18:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901144#M356138</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2023-11-01T18:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901145#M356139</link>
      <description>&lt;P&gt;Sample size?&lt;/P&gt;
&lt;P&gt;Proportion that is significant?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No clue without an idea of where you started. Something that doesn't show up as significant for a proportion at a sample size of 20 may well when the sample gets to 20,000.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 18:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901145#M356139</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-11-01T18:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901146#M356140</link>
      <description>&lt;P&gt;So, in a data step loop, increment or decrement the counts by 1 in each cell, and&amp;nbsp;you can program the Chi-Squared formula based on the number of counts in each cell, and compute the value of its CDF or PDF for each iteration in the loop.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 18:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901146#M356140</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-01T18:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901149#M356141</link>
      <description>&lt;P&gt;You can implement the method in the DATA step with a 4-element array. You just have to decide on a convention for storing the elements of a 2x2 table into the array.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 19:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901149#M356141</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-01T19:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901800#M356375</link>
      <description>&lt;P&gt;I am trying to find an efficient way given just this information that I can calculate how many non-events would need to become events to make the pvalue significant using a two-tailed Fisher's exact test. My datalines are below for the 2 studies I am looking at. Datalines will likely be how I have to create a data set to start, so, if possible, a starting point like my datalines would be helpful. Thank you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dataset;
	input study $ num1 denom1 num2 denom2 pvalue;
	datalines ;
	A 14 33 8 37 0.071
	B 10 33 5 37 0.143
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Nov 2023 20:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901800#M356375</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2023-11-06T20:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901834#M356386</link>
      <description>&lt;P&gt;Is the first p=value supposed to by 0.0751?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To make sure I understand:&lt;/P&gt;
&lt;P&gt;- The first line is for Study A. That study has two groups.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; For Group 1, there were 14 events out 33 subjects (so 19 nonevents). For Group 2, there were 8 events out of 37 subjects (so 29 nonevents)&lt;/P&gt;
&lt;P&gt;- The second line is for Study B.&amp;nbsp;For Group 1, there were 10 events out 33 subjects (so 23 nonevents). For Group 2, there were 5 events out of 37 subjects (so 32 nonevents)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, there is not a unique answer to your question. Many pairs of events will lead to statistically significant results. For example, when there are 0 events in Group1 and 22 events in Group2, that will be significant. Also, when there are 22 events in Group1 and 0 events in Group2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's one way to use the DATA step to loop over all possible 2x2 tables that have the observed row sum and column sum.&amp;nbsp; Then call PROC FREQ on each table. You can use additional logic to get the answer you want, after you define which of the many tables you want to choose. For now, I will just plot the p-values versus the number of events for Group 1. (You could use the number of non-events, if you prefer.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* for each study, numerate over the (1,1) Cell */
data dataset;
input study $ num1 denom1 num2 denom2 pvalue;
N = denom1 + denom2;
sumEvents = num1 + num2;
do x = 0 to SumEvents;
   /* write a 2x2 table for PROC FREQ to analyze */
   Group=1; Event=1; Count=x;           output;
   Group=1; Event=0; Count=denom1-x;    output;
   Group=2; Event=1; Count=SumEvents-x; output;
   Group=2; Event=0; Count=denom2-SumEvents+x; output;
end;
datalines ;
A 14 33 8 37 0.0751
B 10 33 5 37 0.143
;

/* run PROC FREQ on all tables and get the two-sided p-values */
ods select none;
proc freq data=dataset;
   by study x;
   tables Event*Group / norow nocol nopercent;
   exact fisher;
   weight Count;
   ods output FishersExact=FisherOut(where=(Name1='XP2_FISH'));
run;
ods select all;

/* perform an additional analysis to display the values you are looking for. 
   here, I simply plot the results so you can see the p-values as a function 
   of the number of successes in Group 1 */
title "p-value for Fisher Exact Test";
proc sgpanel data=FisherOut;
   panelby study;
   series x=x y=nValue1 / markers;
   refline 0.05 / axis=y label='0.05';
   colaxis grid label="Num Events for Group 1";
   rowaxis grid label="Two-Sided p-value";
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPanel5.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89472i72ADF5CEF5AF9458/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SGPanel5.png" alt="SGPanel5.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In Study A, the Exact Test is significant if the number of events is 6 or less, or 15 or more. &lt;BR /&gt;In Study B, the Exact Test is significant if the number of events is 3 or less, or 11 or more.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 01:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901834#M356386</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-07T01:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901894#M356399</link>
      <description>&lt;P&gt;Rick, &lt;BR /&gt;You understand the setup of my datalines correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea is to find the minimum number of events that need to change in order to reverse the pvalue from &amp;gt;0.05 to &amp;lt;0.05.&lt;/P&gt;
&lt;P&gt;It looks like the code you provided shows that. Is it possible, instead of on a graph, to show a table of the changes? Something like below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;# of events changed&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pvalue(hypothetical)&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.061&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.053&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.047&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 15:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901894#M356399</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2023-11-07T15:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901905#M356403</link>
      <description>&lt;P&gt;Sure. Only output the records where the pValue &amp;lt;= 0.05 that are in the left tail:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* find the largest number of events in the left tail for which
   the p-value is less than 0.05. If desired, add "# events changed" column  */
data SolnLeftTail;
   set FisherOut(rename=(nValue1=pValue));
   by Study;
   retain foundMax;
   if first.study then do;
      maxLeftEvents = .;
      foundMax = 0;
   end;
   if NOT foundMax then do;
      if pValue &amp;lt;= 0.05 then do;
         maxLeftEvents = x;
         output;
      end;
      else
         foundMax = 1;
   end;
run;

proc print data=SolnLeftTail; 
   var Study x pValue;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in the left tail of each study. I'll let you figure out the "# of events changed" column:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 17:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/901905#M356403</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-07T17:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/904278#M357284</link>
      <description>&lt;P&gt;Rick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I could get more help. Attached is my code. I have applied the code as you laid out, but I am not able to replicate previous numbers that I have calculating the RFI. I have studies A-D with the numerator and denominator in my datalines. I know from previous research that the RFI for each study is 5, 5, 10 and 4. I am trying to reproduce the same code so that I can use SAS moving forward for these calculations. Again, the goal is to see the minimum number of nonevents that need to change to an event for each outcome measure&amp;nbsp;in order for the nonsignificant p-value, as measured by Fisher's exact test, to become significant. Alpha level 0.05. Any help is greatly appreciated. Thank you&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data rfi;
	input study $ num1 denom1 num2 denom2;
	N = denom1 + denom2;
	sumEvents = num1 + num2;
	do x = 0 to SumEvents;
   /* write a 2x2 table for PROC FREQ to analyze */
   Group=1; Event=1; Count=x;           output;
   Group=1; Event=0; Count=denom1-x;    output;
   Group=2; Event=1; Count=SumEvents-x; output;
   Group=2; Event=0; Count=denom2-SumEvents+x; output;
	end;
	datalines;
	A 3 151 3 149
	B 3 151 2 149
	C 5 125 2 50
	D 3 57 2 60
;
run;

ods select none;
proc freq data=rfi;
   by study x;
   tables Event*Group / norow nocol nopercent;
   exact fisher;
   weight Count;
   ods output FishersExact=FisherOut(where=(Name1='XP2_FISH'));
run;
ods select all;
	
proc sgpanel data=FisherOut;
   panelby study;
   series x=x y=nValue1 / markers;
   refline 0.05 / axis=y label='0.05';
   colaxis grid values=(0 1 2 3 4 5 6 7 8 9 10) label="Num Events for Group 1";
   rowaxis grid label="Two-Sided p-value";
run;

data SolnLeftTail;
   set FisherOut(rename=(nValue1=pValue));
   by Study;
   retain foundMax;
   if first.study then do;
      maxLeftEvents = .;
      foundMax = 0;
   end;
   if NOT foundMax then do;
      if pValue &amp;lt;= 0.05 then do;
         maxLeftEvents = x;
         output;
      end;
      else
         foundMax = 1;
   end;
run;

proc print data=SolnLeftTail; 
   var Study x pValue;
run;
*RFI- Study A - 5
	  Study B - 5
	  Study C - 10
	  Study D - 4;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2023 19:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/904278#M357284</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2023-11-22T19:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/904280#M357285</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; I know from previous research that the RFI for&amp;nbsp;each study is 5, 5, 10 and 4.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, the most likely explanation is that I misunderstood what you are asking for. So you need to clarify the problem. Please explain the above statement by constructing an example for Study A that runs Fisher's Exact Test and results in a significant p-value. In my previous response, I interpreted '5' for Study A to mean the following frequency table and analysis:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
input Group Event Count;
datalines;
1 1 5
1 0 146
2 1 1
2 0 148
;

proc freq data=A;
   tables Event*Group / norow nocol nopercent;
   exact fisher;
   weight Count;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please explain what table you want to analyze for Study A when '5' is used. Also, explain the logic by which you obtained the table.&amp;nbsp; Then do the same explanation for Study C, which uses '10'.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2023 19:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/904280#M357285</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-22T19:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/904696#M357419</link>
      <description>&lt;P&gt;Rick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a method to review already published data. Below are the datalines for this table. The p-value for this dichotomous outcome is &amp;gt;0.05.&amp;nbsp;T&lt;SPAN&gt;he goal is to see the minimum number of nonevents that need to change to an event for each outcome measure&amp;nbsp;in order for the nonsignificant p-value, as measured by Fisher's exact test, to become significant. Alpha level 0.05. Based on previous analysis, I know the minimum number of events needed is 5 for this study and want to determine a way to replicate the analysis in SAS.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	input study $ group $ outcome $;
	datalines;
		A	Exp	Yes
		A	Exp	Yes
		A	Exp	Yes
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Exp	No
		A	Con	Yes
		A	Con	Yes
		A	Con	Yes
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		A	Con	No
		;
run;

proc freq data= want;
	table group*outcome /chisq fisher;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Nov 2023 19:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/904696#M357419</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2023-11-27T19:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing a Pvalue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/904770#M357432</link>
      <description>&lt;P&gt;Please explain the statement &lt;SPAN&gt;"Based on previous analysis, I know the minimum number of events needed is 5 for this study."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;When I run your DATA step, I see it is equivalent to the following shorter program:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
   length Study $1 Group $3 Outcome $3;
	input study $ group $ outcome $ Count;
	datalines;
A	Con	No  146
A	Con	Yes   3
A	Exp   No  148
A	Exp	Yes   3
;

proc freq data= Have;
	table group*outcome /chisq fisher norow nocol nopercent;
   weight count;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;You say that you can change 5 nonevents to events and get a significant p-value. Please show how. Here is a new data set in which I have changed 5 nonevents in the experimental group to events. Upon rerunning the analysis, I do not get a significant p-value:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data New;
   length Study $1 Group $3 Outcome $3;
	input study $ group $ outcome $ Count;
	datalines;
A	Con	No  146
A	Con	Yes   3
A	Exp   No  143
A	Exp	Yes   8
;

proc freq data= New;
	table group*outcome /chisq fisher norow nocol nopercent;
   weight count;
   exact fisher;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;If I change 5 observations from Yes to No in the control group, I also do not get a significant p-value. Show me what you do to the original data to get a significant p-value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 00:31:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-a-Pvalue/m-p/904770#M357432</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-28T00:31:54Z</dc:date>
    </item>
  </channel>
</rss>

