<?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: Random Sampling in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367806#M24072</link>
    <description>&lt;P&gt;The count is the ID frequency output from the proc freq. So, if an ID is in the dataset, then it would have at least a frequency of 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, the latter. The 'size count;' is telling&amp;nbsp;&lt;SPAN&gt;SAS that the sampling needs to be done by taking into account this variable which is the frequency of records. This statement needs to be in the procedure if you use 'method=pps'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;EM&gt;Source:&lt;/EM&gt;&amp;nbsp;&lt;A href="https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_surveyselect_sect007.htm#statug.surveyselect.methodpps" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_surveyselect_sect007.htm#statug.surveyselect.methodpps&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Jun 2017 17:10:11 GMT</pubDate>
    <dc:creator>Rwon</dc:creator>
    <dc:date>2017-06-16T17:10:11Z</dc:date>
    <item>
      <title>Random Sampling</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367294#M24039</link>
      <description>&lt;P&gt;My original data set contains 7 records, with one "Newic-890426" containing 5 entries while the other "NEWIC-900120". I intend to randomly select 2 records &lt;STRONG&gt;(Criteria:UNIQUE NEWIC)&lt;/STRONG&gt; using the proc survey select method. But i notice it is still possible that SAS picks two (2) of the same NEWIC.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do NOT intend to remove the duplicates prior to selecting as the sole reason as to why certain NEWICs have multiple records because they have earlier fulfilled certain criteria, thus enabling them to stand a "higher chance" of being selected.&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;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyselect data=test1 out=test2
method=srs 
n=2 NOPRINT;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13956i5D80193353084F94/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Untitled.png" title="Untitled.png" /&gt;</description>
      <pubDate>Thu, 15 Jun 2017 09:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367294#M24039</guid>
      <dc:creator>FastLearner89</dc:creator>
      <dc:date>2017-06-15T09:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Random Sampling</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367464#M24049</link>
      <description>&lt;P&gt;Could you elaborate on the number of unique records in the original dataset? You listed 2&amp;nbsp;unique records and ideally want to randomly select 2 unique records using surveyselect. Is this correct?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regardless, I think you should look into 'method = pps', which is probability proportion to size, rather than srs. You would need to add an intermediary step to make the records unique, such as proc freq, while keeping their count which would&amp;nbsp;&lt;SPAN&gt;enable them to stand a "higher chance" of being selected.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is SAS's explanation of the PPS method:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_surveyselect_a0000000157.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_surveyselect_a0000000157.htm&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*I used ID to illustrate the method;
data test1;
input id $3.;
datalines;
012
111
123
456
789
012
111
111
111
;
run;

*Unique ID level with count to be used as the probability of selection;
proc freq data = test1;
tables id / out = test_freq ( keep = id count );
run;

*Random selection with count as the probability of selection of ID;
proc surveyselect data = test_freq out = test2 method = pps n = 2 noprint;
size count;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 17:52:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367464#M24049</guid>
      <dc:creator>Rwon</dc:creator>
      <dc:date>2017-06-15T17:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Random Sampling</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367801#M24071</link>
      <description>Indeed the original data set only has 2 unique records. I intentionally duplicated some of the entries (IDs) to show that i intend to have certain IDs picked more often than the others.&lt;BR /&gt;&lt;BR /&gt;By the way, that the "size: count" have any contraints tied to it?Eg. Count needs to be more than 1? Or is "count" merely to tell SAS that the sampling needs to be done by taking into account *this* variable which is the frequency of records.&lt;BR /&gt;&lt;BR /&gt;Also, thanks for your help!&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Jun 2017 16:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367801#M24071</guid>
      <dc:creator>FastLearner89</dc:creator>
      <dc:date>2017-06-16T16:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Random Sampling</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367806#M24072</link>
      <description>&lt;P&gt;The count is the ID frequency output from the proc freq. So, if an ID is in the dataset, then it would have at least a frequency of 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, the latter. The 'size count;' is telling&amp;nbsp;&lt;SPAN&gt;SAS that the sampling needs to be done by taking into account this variable which is the frequency of records. This statement needs to be in the procedure if you use 'method=pps'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;EM&gt;Source:&lt;/EM&gt;&amp;nbsp;&lt;A href="https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_surveyselect_sect007.htm#statug.surveyselect.methodpps" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_surveyselect_sect007.htm#statug.surveyselect.methodpps&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 17:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367806#M24072</guid>
      <dc:creator>Rwon</dc:creator>
      <dc:date>2017-06-16T17:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: Random Sampling</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367876#M24079</link>
      <description>&lt;P&gt;If you only want one record for each level of a variable you might try the STRATA statement;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sort the data by the strata variable and then something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc surveyselect data=have out=want sampsize=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; strata stratavariablename;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;will select one record for each level of the given variable.&lt;/P&gt;
&lt;P&gt;You can use any fixed value for sampsize as long as every group of records for a strata has at least that many records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 20:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367876#M24079</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-16T20:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: Random Sampling</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367927#M24082</link>
      <description>If i were to replace the "count" with some other identifier, say variable, and each records have different variable identifier, eg.&lt;BR /&gt;Id Var&lt;BR /&gt;Aa 0.3&lt;BR /&gt;Bb 0.1&lt;BR /&gt;Cc 2&lt;BR /&gt;Dd 3&lt;BR /&gt;&lt;BR /&gt;Would the PPS method still work? I.e. could SAS recognize that ID=Dd stands the highest chance (largest value) followed by Cc, Aa and Bb(smallest value)?</description>
      <pubDate>Sat, 17 Jun 2017 02:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/367927#M24082</guid>
      <dc:creator>FastLearner89</dc:creator>
      <dc:date>2017-06-17T02:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Random Sampling</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/368326#M24113</link>
      <description>&lt;P&gt;Yes, that would still work.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 13:41:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Random-Sampling/m-p/368326#M24113</guid>
      <dc:creator>Rwon</dc:creator>
      <dc:date>2017-06-19T13:41:25Z</dc:date>
    </item>
  </channel>
</rss>

