<?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 selection of  records in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249807#M56556</link>
    <description>&lt;P&gt;this is even shorter.&lt;/P&gt;
&lt;P&gt;Thanks Data_Null, thanks guys&lt;/P&gt;</description>
    <pubDate>Fri, 12 Feb 2016 19:46:13 GMT</pubDate>
    <dc:creator>Tal</dc:creator>
    <dc:date>2016-02-12T19:46:13Z</dc:date>
    <item>
      <title>randomly selection of  records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249535#M56526</link>
      <description>&lt;P&gt;i have a&amp;nbsp; file of students and&amp;nbsp; each student can appear more than once in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;student score&lt;/P&gt;
&lt;P&gt;100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;
&lt;P&gt;100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/P&gt;
&lt;P&gt;100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C&lt;/P&gt;
&lt;P&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;
&lt;P&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/P&gt;
&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;
&lt;P&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/P&gt;
&lt;P&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;
&lt;P&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp; C&lt;/P&gt;
&lt;P&gt;.......&lt;/P&gt;
&lt;P&gt;.........&lt;/P&gt;
&lt;P&gt;i need to randomly select maximum to 2 records per student&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea how to achieve this guys please? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 20:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249535#M56526</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2016-02-11T20:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: randomly selection of  records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249542#M56528</link>
      <description>&lt;P&gt;I think this might get you started. Since you may have some students with only one score if we want to use surveyselect which is designed for random sampling we need to describe how many records to pull for each student so the Proc Freq and Data step create a record for each student and if they only have one score then you get one requested, otherwise 2. Note that the output dataset from Surveyselect, Want, will have additional variables that can be used for weighting and tell what the probability of selection was.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have noprint;
   tables student/list out=temp;
run;

data samplesize;
   set temp;
   if count &amp;gt; 1 then _nsize_ = 2;
   else _nsize_ = 1;
run;

proc surveyselect data=have out=want
  sampsize=samplesize ;
  strata student;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2016 20:45:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249542#M56528</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-11T20:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: randomly selection of  records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249547#M56529</link>
      <description>&lt;P&gt;thanks ballardw&lt;/P&gt;
&lt;P&gt;works&amp;nbsp; perfectly&lt;/P&gt;
&lt;P&gt;interesting&amp;nbsp;approach&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thx again&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 21:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249547#M56529</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2016-02-11T21:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: randomly selection of  records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249622#M56538</link>
      <description>&lt;P&gt;The SELECTALL option provides a simplier solution. &amp;nbsp;No counting required.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data student;
   input (student score)($);
   cards;
100 A
100 B
100 C
101 A
101 B
102 A
103 B
103 A
103 C
;;;;
   run;
proc print;
   run;
proc surveyselect data=student seed=4354 n=2 out=sample2 selectall;
   strata student;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1859iB216E68E578EBCF0/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 10:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249622#M56538</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-12T10:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: randomly selection of  records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249793#M56555</link>
      <description>&lt;P&gt;Good point &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__﻿&lt;/a&gt;&amp;nbsp;I wish I could say that I was providing a more general solution where you had different selection rules based on counts within strata. But I just forgot the SELECTALL option as none of my stratified data gets close to the using all of the records in a stratum.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 18:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249793#M56555</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-12T18:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: randomly selection of  records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249807#M56556</link>
      <description>&lt;P&gt;this is even shorter.&lt;/P&gt;
&lt;P&gt;Thanks Data_Null, thanks guys&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 19:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/randomly-selection-of-records/m-p/249807#M56556</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2016-02-12T19:46:13Z</dc:date>
    </item>
  </channel>
</rss>

