<?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: Saving p-values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423427#M68115</link>
    <description>&lt;P&gt;Thank you so much!! It works!&lt;/P&gt;</description>
    <pubDate>Sat, 23 Dec 2017 06:22:35 GMT</pubDate>
    <dc:creator>Amanda_Lemon</dc:creator>
    <dc:date>2017-12-23T06:22:35Z</dc:date>
    <item>
      <title>Saving p-values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423406#M68110</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do a Monte Carlo simulation of ANCOVA. I generated random variables and simulated data from regressions models below. x is a covariate, g is a grouping variable (0 for a control group, 1 for a treatment group), y is a dependent variable. I am manipulating coefficients. In this syntax, I set the treatment effect on y to be 0, the treatment effect on x to be 0.6, and the effect of x on y to be 1. I also set the number of samples to be 1000 and the sample size to be 800 (about a half being a treatment group).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data MC (drop=i);
call streaminit(12345678);
do sampleID = 1 to 1000;
  do i = 1 to 800;
    g = rand("Bernoulli", 0.5);
    x = 0.6*g + rand("Normal"); 
    y = 1*x + 0*g + rand("Normal");
    output;
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So, after that, I need to test the effect of g on y in each of 1000 samples. I wrote this syntax:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glm data = MC;
  BY sampleID; 
  class g;
  model y = g;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It works but the problem is that I need only p values (for F values) from the output to count how many were less then .05 (which will serve as an estimate of Type I error rate). So, I can't figure out how to put these p-values in a data set, an array, or something like that (extracting p-values by hand for 1000 samples is not an option...).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would very much appreciate any help and/or feedback. Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2017 04:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423406#M68110</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-12-23T04:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Saving p-values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423408#M68111</link>
      <description>&lt;P&gt;Start with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc glm data = MC outstat=myStat noprint;
  BY sampleID; 
  class g;
  model y = g x / ss3;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Dec 2017 04:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423408#M68111</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-12-23T04:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Saving p-values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423409#M68112</link>
      <description>&lt;P&gt;Thank you! Now I have one table with all p values!&lt;BR /&gt;&lt;BR /&gt;Last question -- how now to count p that less than 0.05? I though I can use myStat now as a data set and PROB as a variable so that I could simply count through the if statement -- but that doesn't seem to work...&lt;BR /&gt;&lt;BR /&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2017 05:09:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423409#M68112</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-12-23T05:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Saving p-values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423412#M68113</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151986"&gt;@Amanda_Lemon&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thank you! Now I have one table with all p values!&lt;BR /&gt;&lt;BR /&gt;Last question -- how now to count p that less than 0.05? I though I can use myStat now as a data set and PROB as a variable so that I could simply count through the if statement -- but that doesn't seem to work...&lt;BR /&gt;&lt;BR /&gt;Thank you in advance.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What does that code look like, that logic should work fine.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2017 05:24:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423412#M68113</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-23T05:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Saving p-values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423423#M68114</link>
      <description>&lt;P&gt;Here is how to do the counting (for effect g):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc glm data = MC outstat=myStat noprint;
  BY sampleID; 
  class g;
  model y = g x / ss3;
run;

proc sql;
select 
    sum(prob&amp;lt;0.05) as nb_5pct,
    count(prob) as nb_sample,
    sum(prob&amp;lt;0.05) / count(prob) as prop_5pct
from myStat
where _SOURCE_ = "g";
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Dec 2017 06:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423423#M68114</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-12-23T06:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Saving p-values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423427#M68115</link>
      <description>&lt;P&gt;Thank you so much!! It works!&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2017 06:22:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423427#M68115</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-12-23T06:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: Saving p-values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423433#M68116</link>
      <description>&lt;P&gt;An unrelated follow-up question. When I simulate the binary variable g, I use the Bernoulli distribution. I want the two groups to be equal, so I thought that setting the probability to 0.5 will do that. But it produces approximate splits in half (like, 423 and 377). I know I can just assign 0 to g for i from 1 to 400 and 1 to g for i from 401 to 800. But is there a way to _randomly_ assign 0 and 1 to g but have the groups precisely equal (400 and 400)? &lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data MC (drop=i);
call streaminit(12345678);
do sampleID = 1 to 1000;
  do i = 1 to 800;
    g = rand("Bernoulli", 0.5);
    x = 0.6*g + rand("Normal"); 
    y = 1*x + 0*g + rand("Normal");
    output;
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Dec 2017 07:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423433#M68116</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-12-23T07:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Saving p-values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423435#M68117</link>
      <description>&lt;P&gt;There is no advantage&amp;nbsp;in having&amp;nbsp;random g values, as far as I can tell. But if you want, you can do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp (drop=i);
call streaminit(12345678);
do sampleID = 1 to 1000;
    do g = 0, 1;
        do i = 1 to 400;
            rnd = rand("Uniform");
            x = 0.6*g + rand("Normal"); 
            y = 1*x + 0*g + rand("Normal");
            output;
            end;
        end;
    end;
run;

proc sort data=temp out=mc(drop=rnd); 
by sampleId rnd; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2017 07:22:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423435#M68117</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-12-23T07:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Saving p-values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423437#M68118</link>
      <description>That works! Thanks again!!</description>
      <pubDate>Sat, 23 Dec 2017 07:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423437#M68118</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-12-23T07:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Saving p-values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423468#M68121</link>
      <description>&lt;P&gt;I ran into another problem... Everything works just fine when I simulate a normal distribution but when I changed it to a truncated normal distribution, the PROC GLM statement stopped working... (data are simulated fine). When I print the GLM results, it shows that SS for g were not computed (see the screenshot). Why is that? Thank you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data MC (keep = x y g sampleID);
Fa = cdf('Normal', -6, 0, 1); /* for a = -6 */
Fb = cdf('Normal', 6, 0, 1); /* for b = 6 */
call streaminit(12345678);
do sampleID = 1 to 1000;
 do g = 0, 1;
  do i = 1 to 500;
    v = Fa + (Fb-Fa)*rand('Uniform'); /* V ~ U(F(a), F(b)) */
    x = 0*g + quantile('Normal', v, 0, 1); /* truncated normal on [a,b] */
    y = 1*x + 0*g + quantile('Normal', v, 0, 1);
    output;
  end;
 end; 
end;
run;
proc glm data = MC outstat=myStat noprint;
  BY sampleID; 
  class g;
  model y = g x / ss3;
run;
proc print data = myStat; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="print .jpg" style="width: 430px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17522i288197339CC71F76/image-dimensions/430x485?v=v2" width="430" height="485" role="button" title="print .jpg" alt="print .jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2017 22:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423468#M68121</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-12-23T22:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Saving p-values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423476#M68122</link>
      <description>&lt;P&gt;The problem stems from the fact that &lt;EM&gt;y = 2*x&lt;/EM&gt; in all of your simulated observations. To replicate the structure of your previous simulation you would need:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    v = Fa + (Fb-Fa)*rand('Uniform'); /* V ~ U(F(a), F(b)) */
    w = Fa + (Fb-Fa)*rand('Uniform'); /* W ~ U(F(a), F(b)) */
    x = 0*g + quantile('Normal', v, 0, 1); /* truncated normal on [a,b] */
    y = 1*x + 0*g + quantile('Normal', w, 0, 1);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Dec 2017 04:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423476#M68122</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-12-24T04:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Saving p-values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423497#M68125</link>
      <description>Thank you so much!! It works!</description>
      <pubDate>Mon, 25 Dec 2017 06:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Saving-p-values/m-p/423497#M68125</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-12-25T06:20:08Z</dc:date>
    </item>
  </channel>
</rss>

