<?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: How to select a random percent of data to test? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96948#M257799</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more note ... a second thought about generating the percentage to select with ranuni(12345)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you run the program multiple times, you will get the same percentage selected each time because the first random number generated by ranuni(12345) will be the same very time.&amp;nbsp; There are two basic approaches to get around this.&amp;nbsp; One is to switch to ranuni(0) instead of ranuni(12345).&amp;nbsp; The drawback here is that ranuni(0) selects a different random number each time.&amp;nbsp; If you are ever asked to prove that your results are correct, you will not be able to replicate them, let alone prove that they are correct.&amp;nbsp; The second approach involves writing a more complex program (a few approaches are possible).&amp;nbsp; So if you add some details (do you care if the results can be replicated), you're sure to get some feedback.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Jul 2012 18:17:16 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2012-07-02T18:17:16Z</dc:date>
    <item>
      <title>How to select a random percent of data to test?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96944#M257795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm new to sas and I was wondering if it is possible to test a random percent of data. For example, I have a large data set and I want to test between 8% and 20% of the data at random. How would I go about doing something like this? Basically what I have been trying to do is use a do loop with the ranuni command but I can't get my desired specifications. Any help or advice would be much appreciated. Thanks!, &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 13:45:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96944#M257795</guid>
      <dc:creator>Torri92</dc:creator>
      <dc:date>2012-07-02T13:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to select a random percent of data to test?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96945#M257796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It sounds like you need two random number streams.&amp;nbsp; One determines the percentage of observations, then the second actually selects the observations.&amp;nbsp; For example, in this formula 0.06 represents the size of the interval from 0.08 to 0.14:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data subset;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then percent_to_select = 0.08 + 0.06 * ranuni(12345);&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain percent_to_select;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set population;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if ranuni(13579) &amp;lt; percent_to_select;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Here, percent_to_select is continuous.&amp;nbsp; You could apply a function to it, if you want discrete values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 15:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96945#M257796</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-07-02T15:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to select a random percent of data to test?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96946#M257797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc surveyselect data=have out=want samprate=0.2 outall;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable &lt;SPAN class="variable" style="font-style: italic;"&gt;Selected&lt;/SPAN&gt; equals 1 for an observation selected for the sample, and equals 0 for an observation not selected.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 17:34:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96946#M257797</guid>
      <dc:creator>verdantsphinx</dc:creator>
      <dc:date>2012-07-02T17:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to select a random percent of data to test?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96947#M257798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To combine the two previous examples:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let min=0.08;&lt;/P&gt;&lt;P&gt;%let max=0.20;&lt;/P&gt;&lt;P&gt;%let rsr=%sysfunc(round(%sysevalf( &amp;amp;min + ( &amp;amp;max - &amp;amp;min ) * %sysfunc(ranuni(0))),.01));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc surveyselect&lt;/P&gt;&lt;P&gt;data=sashelp.retail&lt;/P&gt;&lt;P&gt;out=want&lt;/P&gt;&lt;P&gt;samprate=&amp;amp;rsr;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 18:00:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96947#M257798</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2012-07-02T18:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to select a random percent of data to test?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96948#M257799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more note ... a second thought about generating the percentage to select with ranuni(12345)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you run the program multiple times, you will get the same percentage selected each time because the first random number generated by ranuni(12345) will be the same very time.&amp;nbsp; There are two basic approaches to get around this.&amp;nbsp; One is to switch to ranuni(0) instead of ranuni(12345).&amp;nbsp; The drawback here is that ranuni(0) selects a different random number each time.&amp;nbsp; If you are ever asked to prove that your results are correct, you will not be able to replicate them, let alone prove that they are correct.&amp;nbsp; The second approach involves writing a more complex program (a few approaches are possible).&amp;nbsp; So if you add some details (do you care if the results can be replicated), you're sure to get some feedback.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 18:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96948#M257799</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-07-02T18:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to select a random percent of data to test?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96949#M257800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is a good thought Astounding.&amp;nbsp; The use of proc surveyselect does lend somewhat to solving this issue.&amp;nbsp; The seed, when not defined, will be selected randomly and also printed out.&amp;nbsp; If you want to repeat a sample you can reuse the seed from the previous run.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 18:37:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-a-random-percent-of-data-to-test/m-p/96949#M257800</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2012-07-02T18:37:17Z</dc:date>
    </item>
  </channel>
</rss>

