<?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: simulating a sample from an empirical distribution in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/simulating-a-sample-from-an-empirical-distribution/m-p/217783#M11780</link>
    <description>&lt;P&gt;This is exactly the example that I use on p. 18-19 of my book &lt;EM&gt;Simulating Data with SAS&lt;/EM&gt;.&amp;nbsp; The code is&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let N = 100;
data Table(keep=x);
call streaminit(4321);
array p[3] _temporary_ (0.5 0.2 0.3);  /* proportions in population */
do i = 1 to &amp;amp;N;
   x = rand("Table", of p[*]);           /* sample with replacement */
   output;
end;
run;&lt;/CODE&gt;&lt;/PRE&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For an explanation and alternatives, see the blog post &lt;A href="http://blogs.sas.com/content/iml/2011/07/13/simulate-categorical-data-in-sas.html" target="_blank"&gt;"Simulate categorical data in SAS."&lt;/A&gt;&lt;/P&gt;&lt;P&gt;By the way, the size of the population doesn't matter. Only the proportions.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Sep 2015 19:29:25 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2015-09-08T19:29:25Z</dc:date>
    <item>
      <title>simulating a sample from an empirical distribution</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/simulating-a-sample-from-an-empirical-distribution/m-p/217780#M11777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;suppose that I have a population of 1000 objects categorized into 3 different types and that 50% of the total objects are Type1, 30% are Type2 and the remaining 20% are Type3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I would like to do is to simulate a sample of 100 objects and randomly classify them into 3 types, and the types having the distribution of the population described above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found how to simulate samples with embedded distributions, but have difficulty with the empirical distribution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 20:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/simulating-a-sample-from-an-empirical-distribution/m-p/217780#M11777</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2015-05-20T20:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: simulating a sample from an empirical distribution</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/simulating-a-sample-from-an-empirical-distribution/m-p/217781#M11778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have a category variable then sort by the category variable and:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc survey select data=have out=want&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sampsize=100;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strata category/ alloc=prop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;might work&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 20:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/simulating-a-sample-from-an-empirical-distribution/m-p/217781#M11778</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-05-20T20:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: simulating a sample from an empirical distribution</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/simulating-a-sample-from-an-empirical-distribution/m-p/217782#M11779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That will give a sample with &lt;EM&gt;exactly&lt;/EM&gt; the same distribution (exactly 50 that are Type 1 etc). If you want to randomly sample, then you also need to know whether you are sampling from a population of size 1000 (without replacement) or from an infinite population.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Briefly, these could be achieved by:&lt;/P&gt;&lt;P&gt;Population size=1000: assign a random number to each observation, sort and take the first 100.&lt;/P&gt;&lt;P&gt;Population size = infinite: generate a set of 100 random numbers between 1 and 1000. Merge this (by a variable containing observation number) with your data set of 1000 keeping those that were in your random number list (may include duplicates, because it is sampling with replacement).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 22:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/simulating-a-sample-from-an-empirical-distribution/m-p/217782#M11779</guid>
      <dc:creator>KenDodds</dc:creator>
      <dc:date>2015-05-20T22:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: simulating a sample from an empirical distribution</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/simulating-a-sample-from-an-empirical-distribution/m-p/217783#M11780</link>
      <description>&lt;P&gt;This is exactly the example that I use on p. 18-19 of my book &lt;EM&gt;Simulating Data with SAS&lt;/EM&gt;.&amp;nbsp; The code is&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let N = 100;
data Table(keep=x);
call streaminit(4321);
array p[3] _temporary_ (0.5 0.2 0.3);  /* proportions in population */
do i = 1 to &amp;amp;N;
   x = rand("Table", of p[*]);           /* sample with replacement */
   output;
end;
run;&lt;/CODE&gt;&lt;/PRE&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For an explanation and alternatives, see the blog post &lt;A href="http://blogs.sas.com/content/iml/2011/07/13/simulate-categorical-data-in-sas.html" target="_blank"&gt;"Simulate categorical data in SAS."&lt;/A&gt;&lt;/P&gt;&lt;P&gt;By the way, the size of the population doesn't matter. Only the proportions.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2015 19:29:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/simulating-a-sample-from-an-empirical-distribution/m-p/217783#M11780</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-09-08T19:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: simulating a sample from an empirical distribution</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/simulating-a-sample-from-an-empirical-distribution/m-p/217784#M11781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;omg I actually bought this book last year and even read section 2.4.5 Tabulated Distributions with the socks example (I even highlighted parts of the text)!!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its just that since then I completely forgot about it...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Rick!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 15:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/simulating-a-sample-from-an-empirical-distribution/m-p/217784#M11781</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2015-05-21T15:25:29Z</dc:date>
    </item>
  </channel>
</rss>

