<?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 Generating Sample Means From Uniform Distribution in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Generating-Sample-Means-From-Uniform-Distribution/m-p/447077#M283311</link>
    <description>&lt;P&gt;Hello. I need to take a sample of 10 random numbers from the Uniform(0,1) distribution then calculate the sample mean. I then need to do this 100 times so that I get 100 sample means all from samples of size 10.&amp;nbsp; Then I need 100 sample means from sample size 100. Then continues on for a total 7 different sample sizes. The resulting data set should have two columns:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; The sample size of the sample that the sample mean was calculated from&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. The sample mean&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It should have 700 entries. 100 for each sample size. I started with nested for loops but I am stuck on how to calculate the sample mean once I obtain the sample. See code below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data uniform (drop = x);&lt;BR /&gt;&amp;nbsp;do n = 10, 100, 200, 500, 1000, 5000, 10000 ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; do i = 1 to 100 ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; do a = 1 to n ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;x = rand('Uniform');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; y = mean(x);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* not right.*/&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; output ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;BR /&gt;end;&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that this does not work because y = mean(x) will just take the mean of one value- the value of x on the nth loop. I can't figure out how to get the mean of just the sample taken in the third do loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Mar 2018 13:05:07 GMT</pubDate>
    <dc:creator>UCFtigers2017</dc:creator>
    <dc:date>2018-03-20T13:05:07Z</dc:date>
    <item>
      <title>Generating Sample Means From Uniform Distribution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generating-Sample-Means-From-Uniform-Distribution/m-p/447077#M283311</link>
      <description>&lt;P&gt;Hello. I need to take a sample of 10 random numbers from the Uniform(0,1) distribution then calculate the sample mean. I then need to do this 100 times so that I get 100 sample means all from samples of size 10.&amp;nbsp; Then I need 100 sample means from sample size 100. Then continues on for a total 7 different sample sizes. The resulting data set should have two columns:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; The sample size of the sample that the sample mean was calculated from&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. The sample mean&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It should have 700 entries. 100 for each sample size. I started with nested for loops but I am stuck on how to calculate the sample mean once I obtain the sample. See code below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data uniform (drop = x);&lt;BR /&gt;&amp;nbsp;do n = 10, 100, 200, 500, 1000, 5000, 10000 ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; do i = 1 to 100 ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; do a = 1 to n ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;x = rand('Uniform');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; y = mean(x);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* not right.*/&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; output ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;BR /&gt;end;&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that this does not work because y = mean(x) will just take the mean of one value- the value of x on the nth loop. I can't figure out how to get the mean of just the sample taken in the third do loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 13:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generating-Sample-Means-From-Uniform-Distribution/m-p/447077#M283311</guid>
      <dc:creator>UCFtigers2017</dc:creator>
      <dc:date>2018-03-20T13:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Sample Means From Uniform Distribution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generating-Sample-Means-From-Uniform-Distribution/m-p/447079#M283312</link>
      <description>&lt;P&gt;You can do this in a data step, you add up all the 10 random numbers and divide by 10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would output the individual x values, and then compute the means in PROC SUMMARY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary nway data=have;
     class n i;
     var x;
     output out=means mean=x_mean;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Mar 2018 13:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generating-Sample-Means-From-Uniform-Distribution/m-p/447079#M283312</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-03-20T13:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Generating Sample Means From Uniform Distribution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generating-Sample-Means-From-Uniform-Distribution/m-p/447105#M283313</link>
      <description>&lt;P&gt;Thanks, I summed and divided in the data step.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data uniform1 (drop = x);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;do n = 10, 100, 200, 500, 1000, 5000, 10000 ;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;do i = 1 to 100 ;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sumx = 0 ;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; do a = 1 to n ;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;x = rand('Uniform');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sumx + x ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;meanx = sumx / n ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; y = meanx ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; output ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run ;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 14:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generating-Sample-Means-From-Uniform-Distribution/m-p/447105#M283313</guid>
      <dc:creator>UCFtigers2017</dc:creator>
      <dc:date>2018-03-20T14:27:23Z</dc:date>
    </item>
  </channel>
</rss>

