<?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 proc surveyselect question: random sample by variable values? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/proc-surveyselect-question-random-sample-by-variable-values/m-p/826004#M40913</link>
    <description>&lt;P&gt;Say I want to select a random sample of 5 car makes (out of the total of 38 different makes) from sashelp.cars and pull all records sharing one of the randomly select 5 car makes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried the following but it returns an error message.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you perform random sampling of records by variable value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars; by make; run;&lt;BR /&gt;
proc surveyselect data=sashelp.cars
out=work.cars_samp
seed=123
method=srs
n=5;
strata make;
run;

ERROR: The sample size, 5, is greater than the number of sampling units, 1.
NOTE: The above message was for the following stratum:
Make=Hummer.
ERROR: The sample size, 5, is greater than the number of sampling units, 2.
NOTE: The above message was for the following stratum:
Make=Isuzu.
ERROR: The sample size, 5, is greater than the number of sampling units, 3.
NOTE: The above message was for the following stratum:
Make=Jeep.
ERROR: The sample size, 5, is greater than the number of sampling units, 3.
NOTE: The above message was for the following stratum:
Make=Land Rover.
ERROR: The sample size, 5, is greater than the number of sampling units, 2.
NOTE: The above message was for the following stratum:
Make=MINI.
ERROR: The sample size, 5, is greater than the number of sampling units, 3.
NOTE: The above message was for the following stratum:
Make=Oldsmobile.
ERROR: The sample size, 5, is greater than the number of sampling units, 2.
NOTE: The above message was for the following stratum:
Make=Scion.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.CARS_SAMP may be incomplete. When this step was stopped there were 155 observations and 17 variables.
WARNING: Data set WORK.CARS_SAMP was not replaced because this step was stopped.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 28 Jul 2022 16:48:52 GMT</pubDate>
    <dc:creator>RobertWF1</dc:creator>
    <dc:date>2022-07-28T16:48:52Z</dc:date>
    <item>
      <title>proc surveyselect question: random sample by variable values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/proc-surveyselect-question-random-sample-by-variable-values/m-p/826004#M40913</link>
      <description>&lt;P&gt;Say I want to select a random sample of 5 car makes (out of the total of 38 different makes) from sashelp.cars and pull all records sharing one of the randomly select 5 car makes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried the following but it returns an error message.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you perform random sampling of records by variable value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars; by make; run;&lt;BR /&gt;
proc surveyselect data=sashelp.cars
out=work.cars_samp
seed=123
method=srs
n=5;
strata make;
run;

ERROR: The sample size, 5, is greater than the number of sampling units, 1.
NOTE: The above message was for the following stratum:
Make=Hummer.
ERROR: The sample size, 5, is greater than the number of sampling units, 2.
NOTE: The above message was for the following stratum:
Make=Isuzu.
ERROR: The sample size, 5, is greater than the number of sampling units, 3.
NOTE: The above message was for the following stratum:
Make=Jeep.
ERROR: The sample size, 5, is greater than the number of sampling units, 3.
NOTE: The above message was for the following stratum:
Make=Land Rover.
ERROR: The sample size, 5, is greater than the number of sampling units, 2.
NOTE: The above message was for the following stratum:
Make=MINI.
ERROR: The sample size, 5, is greater than the number of sampling units, 3.
NOTE: The above message was for the following stratum:
Make=Oldsmobile.
ERROR: The sample size, 5, is greater than the number of sampling units, 2.
NOTE: The above message was for the following stratum:
Make=Scion.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.CARS_SAMP may be incomplete. When this step was stopped there were 155 observations and 17 variables.
WARNING: Data set WORK.CARS_SAMP was not replaced because this step was stopped.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jul 2022 16:48:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/proc-surveyselect-question-random-sample-by-variable-values/m-p/826004#M40913</guid>
      <dc:creator>RobertWF1</dc:creator>
      <dc:date>2022-07-28T16:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: proc surveyselect question: random sample by variable values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/proc-surveyselect-question-random-sample-by-variable-values/m-p/826005#M40914</link>
      <description>&lt;P&gt;Putting MAKE on the CLUSTER statement will have it select 5 different makes, keeping all the observations in each make.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc surveyselect data=sashelp.cars&lt;BR /&gt;out=work.cars_samp&lt;BR /&gt;seed=123&lt;BR /&gt;method=srs&lt;BR /&gt;n=5;&lt;BR /&gt;cluster make;&lt;BR /&gt;run;&lt;BR /&gt;proc freq data=work.cars_samp;&lt;BR /&gt;tables make;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 16:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/proc-surveyselect-question-random-sample-by-variable-values/m-p/826005#M40914</guid>
      <dc:creator>SAS_Rob</dc:creator>
      <dc:date>2022-07-28T16:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: proc surveyselect question: random sample by variable values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/proc-surveyselect-question-random-sample-by-variable-values/m-p/826012#M40915</link>
      <description>&lt;P&gt;Select the makes, then extract the sample:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table makes as
select unique make from sashelp.cars; 
quit;
 
proc surveyselect data=makes n=5 out=makes_5 seed=123; run;

proc sql;
create table cars_samp as
select *
from sashelp.cars
where make in (select make from makes_5);
drop table makes_5;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jul 2022 17:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/proc-surveyselect-question-random-sample-by-variable-values/m-p/826012#M40915</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-07-28T17:01:55Z</dc:date>
    </item>
  </channel>
</rss>

