<?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 get unequal sized stratified groups from PROC SURVEYSELECT? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/555009#M27576</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270201"&gt;@Watts&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That does the trick.&amp;nbsp; Thank you also to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;for contributing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the method of choosing one group and then doing OUTALL to get the rest to come along only works for two unequal sized stratified groups.&amp;nbsp; I'm curious about whether there is a way to get more than two unequal sized groups while maintaining the strata proportions.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Apr 2019 13:12:49 GMT</pubDate>
    <dc:creator>Top_Katz</dc:creator>
    <dc:date>2019-04-30T13:12:49Z</dc:date>
    <item>
      <title>How to get unequal sized stratified groups from PROC SURVEYSELECT?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/554879#M27572</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a very simple sampling request.&amp;nbsp; I want to randomly partition a dataset into two groups, stratified on a binary variable.&amp;nbsp; The original data has 1000 observations, 300 with binvar=0, 700 with binvar=1.&amp;nbsp; If I do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SURVEYSELECT DATA=INDS OUT=OUTDS GROUPS=2;&lt;/P&gt;&lt;P&gt;STRATA binvar;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get two groups, identified in the output data set by the variable GroupID.&amp;nbsp; Each group has 500 observations, 150 with binvar=0 and 350 with binvar=1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, how do I get the groups to be of different sizes but still stratified?&amp;nbsp; I want one group of size 600, with 180 binvar=0 and 420 binvar=1, and a second group of size 400, with 120 binvar=0 and 280 binvar=1.&amp;nbsp; If I do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SURVEYSELECT DATA=INDS OUT=OUTDS GROUPS=(600,400);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the two right size groups, but not the exact binvar counts in each one.&amp;nbsp; If I do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SURVEYSELECT DATA=INDS OUT=OUTDS GROUPS=(600,400);&lt;/P&gt;&lt;P&gt;STRATA binvar;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get an error message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: The sum of the GROUPS= values must equal the total number of units.&lt;BR /&gt;NOTE: The above message was for the following stratum:&lt;BR /&gt;binvar=0.&lt;BR /&gt;ERROR: The sum of the GROUPS= values must equal the total number of units.&lt;BR /&gt;NOTE: The above message was for the following stratum:&lt;BR /&gt;binvar=1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can PROC SURVEYSELECT do what I want?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 22:56:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/554879#M27572</guid>
      <dc:creator>Top_Katz</dc:creator>
      <dc:date>2019-04-29T22:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to get unequal sized stratified groups from PROC SURVEYSELECT?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/554885#M27573</link>
      <description>For strata you need to add the allocation option - check the docs for the exact syntax. And...because you’re essentially doing two reps with different sizes, not two groups the easiest solution I can see is multiple PROC SURVEYSELECT calls.</description>
      <pubDate>Tue, 30 Apr 2019 00:58:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/554885#M27573</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-30T00:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to get unequal sized stratified groups from PROC SURVEYSELECT?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/554911#M27574</link>
      <description>&lt;P&gt;Seems like the GROUPS=(n1 n2) option in SURVEYSELECT requires all strata to be the same size. Probably simpler to use a data step program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
call streaminit(768631);
set sashelp.class;
rnd = rand("uniform");
run;

proc sort data=class; by sex rnd; run;

data sample;
do _i = 1 by 1 until(last.sex); 
    set class; by sex;
    end;
do _j = 1 by 1 until(last.sex);
    set class; by sex;
    grp = (_j / _i) &amp;gt; 0.3;
    output;
    end;
drop rnd _i _j;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Apr 2019 03:39:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/554911#M27574</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-04-30T03:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to get unequal sized stratified groups from PROC SURVEYSELECT?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/554924#M27575</link>
      <description>&lt;P&gt;For two groups, you can use N=(180,420) together with the OUTALL option (which includes all observations, selected and not selected, in the output data set).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyselect data=inds out=outds n=(180,420) outall;
strata binvar;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For binvar=0, this selects 180 obs for one group (output data set variable 'Selected'=1) and the remaining 120 obs ('Selected'=0) for the other group..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For binvar=1, this selects 420 obs for one group and the remaining 280 obs for the other group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 05:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/554924#M27575</guid>
      <dc:creator>Watts</dc:creator>
      <dc:date>2019-04-30T05:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to get unequal sized stratified groups from PROC SURVEYSELECT?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/555009#M27576</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270201"&gt;@Watts&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That does the trick.&amp;nbsp; Thank you also to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;for contributing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the method of choosing one group and then doing OUTALL to get the rest to come along only works for two unequal sized stratified groups.&amp;nbsp; I'm curious about whether there is a way to get more than two unequal sized groups while maintaining the strata proportions.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 13:12:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/555009#M27576</guid>
      <dc:creator>Top_Katz</dc:creator>
      <dc:date>2019-04-30T13:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to get unequal sized stratified groups from PROC SURVEYSELECT?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/555095#M27580</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/145776"&gt;@Top_Katz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270201"&gt;@Watts&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That does the trick.&amp;nbsp; Thank you also to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;for contributing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the method of choosing one group and then doing OUTALL to get the rest to come along only works for two unequal sized stratified groups.&amp;nbsp; I'm curious about whether there is a way to get more than two unequal sized groups while maintaining the strata proportions.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Details about what you might mean by "unequal group: and "maintaining strata proportions".&lt;/P&gt;
&lt;P&gt;You can specify a sample size (n or sampsize), number of observations, or a sample rate (samprate or rate) for each level of your STRATA variable. If the strata variable has 5 levels and I want to sample at 20%, 15%, 33%, 10% and 18% for the strata then&lt;/P&gt;
&lt;P&gt;samprate = (20 15 33 10 18) or samprate=(.2 .15 .33 .1 .18) would work.&lt;/P&gt;
&lt;P&gt;If you have two strata variables the listing order gets a bit more complicated but each combination of the strata variables gets a single rate.&lt;/P&gt;
&lt;P&gt;Or N if you want to sample 5 different numbers of observations.&lt;/P&gt;
&lt;P&gt;There are also some options on the STRATA statement such as ALLOC or ALLOCMIN or MARGIN that may be of interest.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 15:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/555095#M27580</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-30T15:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to get unequal sized stratified groups from PROC SURVEYSELECT?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/555129#M27582</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for responding.&amp;nbsp; My strata variable, binvar, has two levels.&amp;nbsp; The original data set has 1,000 records, 300 with binvar=0 and 700 with binvar=1.&amp;nbsp; Suppose I want to create three sample groups.&amp;nbsp; If I do:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC SURVEYSELECT DATA=INDS OUT=OUTDS GROUPS=3;&lt;/P&gt;&lt;P&gt;STRATA binvar;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then I get two groups with 100 binvar=0 and 233 binvar=1, and a third group with 100 binvar=0 and 234 binvar=1.&amp;nbsp; It tries to make the groups of equal size, and it maintains the overall strata variable proportionality within each group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But suppose I want three groups:&lt;/P&gt;&lt;P&gt;group one with 500 total records, 150 binvar=0 and 350 binvar=1&lt;/P&gt;&lt;P&gt;group two with 300 total records, 90 binvar=0 and 210 binvar=1&lt;/P&gt;&lt;P&gt;group three with 200 total records, 60 binvar=0 and 140 binvar=1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I do that with one call to PROC SURVEYSELECT?&amp;nbsp; Or do I have to do successive calls?&amp;nbsp; For example, I could do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SURVEYSELECT DATA=INDS OUT=OUTDS1 GROUPS=2;&lt;/P&gt;&lt;P&gt;STRATA binvar;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SURVEYSELECT DATA=OUTDS1 (WHERE=(GroupID=2)) OUT=OUTDS2 N=(90,21) OUTALL;&lt;/P&gt;&lt;P&gt;STRATA binvar;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA OUTDS;&lt;/P&gt;&lt;P&gt;SET&amp;nbsp;OUTDS1 (WHERE=(GroupID=1)) OUTDS2;&lt;/P&gt;&lt;P&gt;GroupID=IFN((Selected=0),3,GroupID);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This gives me the three groups I sought, but it's clunky.&amp;nbsp; Is it possible to do all this with one PROC SURVEYSELECT call?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 16:56:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/555129#M27582</guid>
      <dc:creator>Top_Katz</dc:creator>
      <dc:date>2019-04-30T16:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to get unequal sized stratified groups from PROC SURVEYSELECT?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/555160#M27583</link>
      <description>&lt;P&gt;In its current version, proc surveyselect isn't capable of handling your request for more than 2 groups. However, the workaround I provided can easily be extended to three or more groups. For example :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;grp = ((_j / _i) &amp;gt; 0.3) + ((_j / _i) &amp;gt; 0.6);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Apr 2019 18:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-get-unequal-sized-stratified-groups-from-PROC/m-p/555160#M27583</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-04-30T18:10:27Z</dc:date>
    </item>
  </channel>
</rss>

