<?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: generate a randum number (0,1) according to a predetermined % sample in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/generate-a-randum-number-0-1-according-to-a-predetermined-sample/m-p/84047#M256851</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The 0,1 will be called selected.&lt;BR /&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;surveyselect&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=sashelp.cars &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;rate&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;.05&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=samp &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;outall&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Jul 2013 11:47:04 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2013-07-19T11:47:04Z</dc:date>
    <item>
      <title>generate a randum number (0,1) according to a predetermined % sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/generate-a-randum-number-0-1-according-to-a-predetermined-sample/m-p/84046#M256850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi everyone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i received a portfolio database of clients who received a loan. i know for a given month the total % of default (eg 5.0%), but i do not have the detail for every client.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i would like to generate for every client (row) a random number (0 or 1), with the "1" meaning a default situation, but i want also the total of "1" being the 5% of the total of rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks in advance for every suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jul 2013 11:29:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/generate-a-randum-number-0-1-according-to-a-predetermined-sample/m-p/84046#M256850</guid>
      <dc:creator>progster</dc:creator>
      <dc:date>2013-07-19T11:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: generate a randum number (0,1) according to a predetermined % sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/generate-a-randum-number-0-1-according-to-a-predetermined-sample/m-p/84047#M256851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The 0,1 will be called selected.&lt;BR /&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;surveyselect&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=sashelp.cars &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;rate&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;.05&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=samp &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;outall&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jul 2013 11:47:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/generate-a-randum-number-0-1-according-to-a-predetermined-sample/m-p/84047#M256851</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-07-19T11:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: generate a randum number (0,1) according to a predetermined % sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/generate-a-randum-number-0-1-according-to-a-predetermined-sample/m-p/84048#M256852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are two ways to interpret the "5%" criterion. The first way is to compute R=int(0.05*N) where N is the number of observations in your data set. Data_Null_ provides code to generate an indicator variable that has R selected rows. Notice that if you run PROC FREQ like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=samp;&lt;/P&gt;&lt;P&gt;tables selected;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you will always get the same number of selected rows (R = int(0.05*428) = 22 in _NULL_'s example).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An alternative approach is to say that each observation has a 5% chance of being selected. This means that the number of selected observations is a random value with expected value 0.05*N.&amp;nbsp; If you take this approach, every time you run the following program you get a different number of selected rows. The number of rows is binomially distributed. It's equivalent to using selected=rand("Binomial",0.05) in a DATA step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc surveyselect data=sashelp.cars &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; method=bernoulli rate=.05 out=samp outall; &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc freq data=samp;&lt;/P&gt;&lt;P&gt;tables selected;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your eventual goal is to do some kind of bootstrap analysis, know that PROC SURVEYSELECT supports the REPS= option, which repeats this selecting process a specified number of times.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jul 2013 13:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/generate-a-randum-number-0-1-according-to-a-predetermined-sample/m-p/84048#M256852</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-07-19T13:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: generate a randum number (0,1) according to a predetermined % sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/generate-a-randum-number-0-1-according-to-a-predetermined-sample/m-p/84049#M256853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dear rick, the advice that definitely match my goals is the second! one last doubt, since i saw that the sample size slightly change, this change is based on a confidence interval? thanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jul 2013 15:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/generate-a-randum-number-0-1-according-to-a-predetermined-sample/m-p/84049#M256853</guid>
      <dc:creator>progster</dc:creator>
      <dc:date>2013-07-19T15:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: generate a randum number (0,1) according to a predetermined % sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/generate-a-randum-number-0-1-according-to-a-predetermined-sample/m-p/84050#M256854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The number of selected rows will be binomially distributed. The expected number of selected rows (the mean) will be N*p.&lt;/P&gt;&lt;P&gt;The standard deviation will be sqrt(N*p*(1-p)). When N is large, most of the sample sizes will be within three standard deviations of the mean.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jul 2013 15:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/generate-a-randum-number-0-1-according-to-a-predetermined-sample/m-p/84050#M256854</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-07-19T15:40:42Z</dc:date>
    </item>
  </channel>
</rss>

