<?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: Randomly selected records in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141818#M261626</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;thanks Astounding,&lt;/P&gt;&lt;P&gt;thanks guys&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Dec 2014 19:33:49 GMT</pubDate>
    <dc:creator>Tal</dc:creator>
    <dc:date>2014-12-09T19:33:49Z</dc:date>
    <item>
      <title>Randomly selected records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141814#M261622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;Hi guys,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;I have a table of 10,000 records which has a variable “type” that has 2 values only (yes and no)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;I am supposed to create 6 groups out of this table and all the selections need to be random ( at least the first 4 group have to be created by picking randomly)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;Group 1 will have 100 randomly selected records with type=yes and then I label it with group=’Group1’&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;Group 2 will have 100 randomly selected records with type=no and gets a label group=’Group2’&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;Group 3 will have 100 randomly selected records with type=yes and group=’Group3’&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;Group 4 will have 100 randomly selected records with type=no and group=’Group4’ &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;The remaining 9,600 records will go in group5 (type=yes) and group6 (type=no) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;Records cannot overlap &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; font-size: 10pt;"&gt;Any ideas please?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Dec 2014 20:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141814#M261622</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2014-12-08T20:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly selected records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141815#M261623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not really seeing the difference between groups 1 / 3 and 2/4 unless you mean you need two disjoint subsets with 100 each of Yes and two sets with no.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc surveyselect will do this. Your strata is the variable with yes/no values (assuming NO other values), sample size is 100 and REPS = 2. The output data set will include a variable to indicate which replicate each record is in within the strata values.&lt;/P&gt;&lt;P&gt;If you you OUTALL you will have all the information you need to assign your group values by examining the variable SELECTED which will have values of 1 for those selected and 0 otherwise(group 5). Strata = Yes and Replicate = 1 or 2 go to Groups 1 and 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adding your group variable will require a pass through a datastep.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Dec 2014 21:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141815#M261623</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-12-08T21:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly selected records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141816#M261624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you prefer to program this yourself, rather than using the "black box" approach of PROC SURVEYSELECT, you can do it by assigning a random number to each observation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; random_number = ranuni(12345);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by type random_number;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by type;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if first.type then counter=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else counter + 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if type='yes' then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if counter &amp;lt;= 100 then group='Group1';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if counter &amp;lt;= 200 then group='Group3';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else group='Group5';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else if type='no' then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if counter &amp;lt;= 100 then group='Group2';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if counter &amp;lt;= 200 then group='Group4';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else group='Group6';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; drop counter random_number;&lt;/P&gt;&lt;P&gt;run;&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, 08 Dec 2014 22:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141816#M261624</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-12-08T22:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly selected records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141817#M261625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks Ballardw&lt;/P&gt;&lt;P&gt;I heard of this Proc surveyselect a lot and&amp;nbsp;&amp;nbsp; did&amp;nbsp; try to use&amp;nbsp; it but it seems like within this proc i cannot create a&amp;nbsp; new variable. Is that really the case&amp;nbsp; or did i do something wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 19:32:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141817#M261625</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2014-12-09T19:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly selected records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141818#M261626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;thanks Astounding,&lt;/P&gt;&lt;P&gt;thanks guys&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 19:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141818#M261626</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2014-12-09T19:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly selected records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141819#M261627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I mentioned you would have to take another pass through the data to add another variable. The only variables that surveyselect adds are related to weighting and selection, not general calculation. However the combination of strata, replicate and selected sufficiently identify the records such that depending on what will be done with the data the group variable could be moot. Any other general manipulation not involving those variables should be done prior to selection.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 20:37:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-selected-records/m-p/141819#M261627</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-12-09T20:37:10Z</dc:date>
    </item>
  </channel>
</rss>

