<?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 choose different random sample sizes using proc surveyselect? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-different-random-sample-sizes-using-proc/m-p/898646#M355209</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Make a dataset for this purpose.*/
DATA have;
  input individual &amp;amp; $char10. firm year num;
  length individual $10;
DATALINES;
100004-77	1001	2004	3
100004-77	1004	2004	3
100004-77	1006	2004	3
100004-77	1008	2004	3
100004-77	1013	2004	3
100004-77	1015	2004	3
119561-14	1003	2006	5
119561-14	1004	2006	5
119561-14	1005	2006	5
119561-14	1008	2006	5
119561-14	1009	2006	5
119561-14	1012	2006	5
119561-14	1014	2006	5
119561-14	1015	2006	5
;
RUN;
proc sql;
create table SampleSize as
select distinct individual,year ,num  as SampleSize
 from have;
quit;

proc surveyselect data=have out=want 
	seed=1234 method=srs n=SampleSize; 
	 strata individual year;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 15 Oct 2023 09:48:21 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2023-10-15T09:48:21Z</dc:date>
    <item>
      <title>How to choose different random sample sizes using proc surveyselect?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-different-random-sample-sizes-using-proc/m-p/898633#M355206</link>
      <description>&lt;P&gt;I have data like the following (but millions of rows, this is just an excerpt):&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;DATA have;
  input individual &amp;amp; $char10. firm year num;
  length individual $10;
DATALINES;
100004-77	1001	2004	3
100004-77	1004	2004	3
100004-77	1006	2004	3
100004-77	1008	2004	3
100004-77	1013	2004	3
100004-77	1015	2004	3
119561-14	1003	2006	5
119561-14	1004	2006	5
119561-14	1005	2006	5
119561-14	1008	2006	5
119561-14	1009	2006	5
119561-14	1012	2006	5
119561-14	1014	2006	5
119561-14	1015	2006	5

;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to randomly select a sample for each individual year group based on the number in num, e.g., for individual=100004-77 and year=2004, I want to pick a random sample of size 3. I tried the following, but it does not work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyselect data=have out=want 
	seed=1234 method=srs n=num; 
	 strata individual year;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I need to automate this because I have considerably many more rows, so I can't simply create two different datasets based on each individual-year combination then manually enter the sample size. Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Oct 2023 02:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-different-random-sample-sizes-using-proc/m-p/898633#M355206</guid>
      <dc:creator>elbarto</dc:creator>
      <dc:date>2023-10-15T02:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose different random sample sizes using proc surveyselect?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-different-random-sample-sizes-using-proc/m-p/898646#M355209</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Make a dataset for this purpose.*/
DATA have;
  input individual &amp;amp; $char10. firm year num;
  length individual $10;
DATALINES;
100004-77	1001	2004	3
100004-77	1004	2004	3
100004-77	1006	2004	3
100004-77	1008	2004	3
100004-77	1013	2004	3
100004-77	1015	2004	3
119561-14	1003	2006	5
119561-14	1004	2006	5
119561-14	1005	2006	5
119561-14	1008	2006	5
119561-14	1009	2006	5
119561-14	1012	2006	5
119561-14	1014	2006	5
119561-14	1015	2006	5
;
RUN;
proc sql;
create table SampleSize as
select distinct individual,year ,num  as SampleSize
 from have;
quit;

proc surveyselect data=have out=want 
	seed=1234 method=srs n=SampleSize; 
	 strata individual year;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Oct 2023 09:48:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-different-random-sample-sizes-using-proc/m-p/898646#M355209</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-10-15T09:48:21Z</dc:date>
    </item>
  </channel>
</rss>

