<?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 sampiling studetns from K out of N schools by 3 stratum leves? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sampiling-studetns-from-K-out-of-N-schools-by-3-stratum-leves/m-p/610686#M177878</link>
    <description>&lt;DIV class="lia-message-heading lia-component-message-header"&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-standard"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-left"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;&lt;DIV class="lia-message-subject"&gt;sampiling studetns from K out of N schools by 3 stratum leves?&lt;DIV class="MessageReadByModeratorCell lia-moderation-moderated"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-04 lia-quilt-column-right"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;&lt;DIV class="lia-message-options"&gt;&lt;DIV class="lia-menu-navigation-wrapper lia-menu-action message-menu"&gt;&lt;DIV class="lia-menu-navigation"&gt;&lt;DIV class="dropdown-default-item"&gt;&lt;A title="Show option menu" href="https://communities.sas.com/t5/SAS-Programming/sampiling-studetns-from-K-out-of-N-schools-by-3-stratum-leves/m-p/609668#" target="_blank" rel="noopener"&gt;Options&lt;/A&gt;&lt;DIV class="dropdown-positioning"&gt;&lt;DIV class="dropdown-positioning-static"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P class="lia-message-dates lia-message-post-date lia-component-post-date-last-edited"&gt;&lt;SPAN class="DateTime lia-message-posted-on lia-component-common-widget-date"&gt;&lt;SPAN class="local-friendly-date"&gt;Thursday&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class="lia-message-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;I would be very happy to help.&lt;/P&gt;&lt;P&gt;First, note that my DATA is registered to every student in a classroom within a school.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My goal is to randomly sample&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;K out of N&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;schools in distict school&lt;BR /&gt;And in each out of the&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;K&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;school, I want to sample to each level of the sample&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;stratum1&lt;/STRONG&gt;, a different number of students&lt;BR /&gt;When at&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;2 levels of the stratum1 we will randomly sample 4 students and at the third level we will sample 5 students&lt;/STRONG&gt;.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;I think to split the sample so that:&lt;BR /&gt;1- Samples&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;K&lt;/STRONG&gt;&amp;nbsp;distinct&amp;nbsp; schools from N schools:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=my_data ; by school;run;&lt;/P&gt;&lt;P&gt;data my_data ;set my_data ;&lt;BR /&gt;by school;&lt;BR /&gt;/*Placing a random number for school and for students*/&lt;BR /&gt;retain&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;uSchool&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;0;&lt;BR /&gt;if first.school then&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;uschool&lt;/STRONG&gt;=ranuni(12222154);&lt;BR /&gt;&lt;STRONG&gt;ustudent&lt;/STRONG&gt;=ranuni(8744);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;ctreate table&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;distinct_schools&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as&lt;/P&gt;&lt;P&gt;select distinict school,&lt;STRONG&gt;uschool&lt;/STRONG&gt;,stratum1,&amp;nbsp;stratum2 ,&amp;nbsp;stratum3,&amp;nbsp;stratum4&lt;/P&gt;&lt;P&gt;from my_data;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=&lt;STRONG&gt;distinct_schools&lt;/STRONG&gt;&amp;nbsp;; by&amp;nbsp;&lt;STRONG&gt;uschool;&lt;/STRONG&gt;run;&lt;/P&gt;&lt;P&gt;proc surveyselect data=&lt;STRONG&gt;distinct_schools&lt;/STRONG&gt;&amp;nbsp; out=&lt;STRONG&gt;K_schools&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;outsorting=k_schools_sort&lt;/P&gt;&lt;P&gt;method=&lt;STRONG&gt;srs&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sampsize=&lt;STRONG&gt;60&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;seed=1234;&lt;/P&gt;&lt;P&gt;control&amp;nbsp;stratum2 stratum3&amp;nbsp; stratum4;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;2- and perform another sample,&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;sample 4 students from the 2 levels of stratum1 and at the third level we will sample 5 students&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;of 4 ostudents from the K schools for the two tiers separately.&lt;BR /&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Students_frame&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;as&lt;/P&gt;&lt;P&gt;select a.school,b.*&lt;/P&gt;&lt;P&gt;from&amp;nbsp;&lt;STRONG&gt;distinct_schools&lt;/STRONG&gt;&amp;nbsp; as a left join my_data as b&lt;/P&gt;&lt;P&gt;on a.school=b.school;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=&lt;STRONG&gt;Students_frame;&lt;/STRONG&gt;&amp;nbsp;by&amp;nbsp; uSchool&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ustudent&amp;nbsp;stratum1&lt;/STRONG&gt;;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc surveyselect data=&lt;STRONG&gt;Students_frame&lt;/STRONG&gt;out=&lt;STRONG&gt;Students_sample&lt;/STRONG&gt;&amp;nbsp;outsorting=&lt;STRONG&gt;sort_Students_sample&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;method=&lt;STRONG&gt;srs&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sampsize=&lt;STRONG&gt;( 4 4 5)&amp;nbsp;&lt;/STRONG&gt;seed=323161;&lt;/P&gt;&lt;P&gt;strata uschool&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;stratum1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;control&amp;nbsp;stratum2 stratum3&amp;nbsp; stratum4;&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;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Do you have another suggestion that you do the sampling in one stroke and not split in two?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 10 Dec 2019 12:17:22 GMT</pubDate>
    <dc:creator>Ash_75</dc:creator>
    <dc:date>2019-12-10T12:17:22Z</dc:date>
    <item>
      <title>sampiling studetns from K out of N schools by 3 stratum leves?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sampiling-studetns-from-K-out-of-N-schools-by-3-stratum-leves/m-p/610686#M177878</link>
      <description>&lt;DIV class="lia-message-heading lia-component-message-header"&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-standard"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-left"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;&lt;DIV class="lia-message-subject"&gt;sampiling studetns from K out of N schools by 3 stratum leves?&lt;DIV class="MessageReadByModeratorCell lia-moderation-moderated"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-04 lia-quilt-column-right"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;&lt;DIV class="lia-message-options"&gt;&lt;DIV class="lia-menu-navigation-wrapper lia-menu-action message-menu"&gt;&lt;DIV class="lia-menu-navigation"&gt;&lt;DIV class="dropdown-default-item"&gt;&lt;A title="Show option menu" href="https://communities.sas.com/t5/SAS-Programming/sampiling-studetns-from-K-out-of-N-schools-by-3-stratum-leves/m-p/609668#" target="_blank" rel="noopener"&gt;Options&lt;/A&gt;&lt;DIV class="dropdown-positioning"&gt;&lt;DIV class="dropdown-positioning-static"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P class="lia-message-dates lia-message-post-date lia-component-post-date-last-edited"&gt;&lt;SPAN class="DateTime lia-message-posted-on lia-component-common-widget-date"&gt;&lt;SPAN class="local-friendly-date"&gt;Thursday&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class="lia-message-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;I would be very happy to help.&lt;/P&gt;&lt;P&gt;First, note that my DATA is registered to every student in a classroom within a school.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My goal is to randomly sample&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;K out of N&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;schools in distict school&lt;BR /&gt;And in each out of the&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;K&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;school, I want to sample to each level of the sample&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;stratum1&lt;/STRONG&gt;, a different number of students&lt;BR /&gt;When at&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;2 levels of the stratum1 we will randomly sample 4 students and at the third level we will sample 5 students&lt;/STRONG&gt;.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;I think to split the sample so that:&lt;BR /&gt;1- Samples&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;K&lt;/STRONG&gt;&amp;nbsp;distinct&amp;nbsp; schools from N schools:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=my_data ; by school;run;&lt;/P&gt;&lt;P&gt;data my_data ;set my_data ;&lt;BR /&gt;by school;&lt;BR /&gt;/*Placing a random number for school and for students*/&lt;BR /&gt;retain&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;uSchool&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;0;&lt;BR /&gt;if first.school then&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;uschool&lt;/STRONG&gt;=ranuni(12222154);&lt;BR /&gt;&lt;STRONG&gt;ustudent&lt;/STRONG&gt;=ranuni(8744);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;ctreate table&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;distinct_schools&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as&lt;/P&gt;&lt;P&gt;select distinict school,&lt;STRONG&gt;uschool&lt;/STRONG&gt;,stratum1,&amp;nbsp;stratum2 ,&amp;nbsp;stratum3,&amp;nbsp;stratum4&lt;/P&gt;&lt;P&gt;from my_data;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=&lt;STRONG&gt;distinct_schools&lt;/STRONG&gt;&amp;nbsp;; by&amp;nbsp;&lt;STRONG&gt;uschool;&lt;/STRONG&gt;run;&lt;/P&gt;&lt;P&gt;proc surveyselect data=&lt;STRONG&gt;distinct_schools&lt;/STRONG&gt;&amp;nbsp; out=&lt;STRONG&gt;K_schools&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;outsorting=k_schools_sort&lt;/P&gt;&lt;P&gt;method=&lt;STRONG&gt;srs&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sampsize=&lt;STRONG&gt;60&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;seed=1234;&lt;/P&gt;&lt;P&gt;control&amp;nbsp;stratum2 stratum3&amp;nbsp; stratum4;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;2- and perform another sample,&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;sample 4 students from the 2 levels of stratum1 and at the third level we will sample 5 students&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;of 4 ostudents from the K schools for the two tiers separately.&lt;BR /&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Students_frame&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;as&lt;/P&gt;&lt;P&gt;select a.school,b.*&lt;/P&gt;&lt;P&gt;from&amp;nbsp;&lt;STRONG&gt;distinct_schools&lt;/STRONG&gt;&amp;nbsp; as a left join my_data as b&lt;/P&gt;&lt;P&gt;on a.school=b.school;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=&lt;STRONG&gt;Students_frame;&lt;/STRONG&gt;&amp;nbsp;by&amp;nbsp; uSchool&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ustudent&amp;nbsp;stratum1&lt;/STRONG&gt;;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc surveyselect data=&lt;STRONG&gt;Students_frame&lt;/STRONG&gt;out=&lt;STRONG&gt;Students_sample&lt;/STRONG&gt;&amp;nbsp;outsorting=&lt;STRONG&gt;sort_Students_sample&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;method=&lt;STRONG&gt;srs&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sampsize=&lt;STRONG&gt;( 4 4 5)&amp;nbsp;&lt;/STRONG&gt;seed=323161;&lt;/P&gt;&lt;P&gt;strata uschool&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;stratum1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;control&amp;nbsp;stratum2 stratum3&amp;nbsp; stratum4;&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;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Do you have another suggestion that you do the sampling in one stroke and not split in two?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 10 Dec 2019 12:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sampiling-studetns-from-K-out-of-N-schools-by-3-stratum-leves/m-p/610686#M177878</guid>
      <dc:creator>Ash_75</dc:creator>
      <dc:date>2019-12-10T12:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: sampiling studetns from K out of N schools by 3 stratum leves?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sampiling-studetns-from-K-out-of-N-schools-by-3-stratum-leves/m-p/610770#M177923</link>
      <description>&lt;P&gt;I would consider creating a data set with my desired sample size and proportion and pass that to SurveySelect.&amp;nbsp;&lt;BR /&gt;The first pass, selecting K/N schools can happen within the data step that creates the proportions/sizes so it will reduce the process to two/three steps overall assuming you need to sort.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/302423"&gt;@Ash_75&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;DIV class="lia-message-heading lia-component-message-header"&gt;
&lt;DIV class="lia-quilt-row lia-quilt-row-standard"&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-left"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;
&lt;DIV class="lia-message-subject"&gt;sampiling studetns from K out of N schools by 3 stratum leves?
&lt;DIV class="MessageReadByModeratorCell lia-moderation-moderated"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-04 lia-quilt-column-right"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;
&lt;DIV class="lia-message-options"&gt;
&lt;DIV class="lia-menu-navigation-wrapper lia-menu-action message-menu"&gt;
&lt;DIV class="lia-menu-navigation"&gt;
&lt;DIV class="dropdown-default-item"&gt;&lt;A title="Show option menu" href="https://communities.sas.com/t5/SAS-Programming/sampiling-studetns-from-K-out-of-N-schools-by-3-stratum-leves/m-p/609668#" target="_blank" rel="noopener"&gt;Options&lt;/A&gt;
&lt;DIV class="dropdown-positioning"&gt;
&lt;DIV class="dropdown-positioning-static"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P class="lia-message-dates lia-message-post-date lia-component-post-date-last-edited"&gt;&lt;SPAN class="DateTime lia-message-posted-on lia-component-common-widget-date"&gt;&lt;SPAN class="local-friendly-date"&gt;Thursday&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV class="lia-message-body"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;I would be very happy to help.&lt;/P&gt;
&lt;P&gt;First, note that my DATA is registered to every student in a classroom within a school.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;My goal is to randomly sample&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;K out of N&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;schools in distict school&lt;BR /&gt;And in each out of the&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;K&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;school, I want to sample to each level of the sample&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;stratum1&lt;/STRONG&gt;, a different number of students&lt;BR /&gt;When at&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;2 levels of the stratum1 we will randomly sample 4 students and at the third level we will sample 5 students&lt;/STRONG&gt;.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;I think to split the sample so that:&lt;BR /&gt;1- Samples&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;K&lt;/STRONG&gt;&amp;nbsp;distinct&amp;nbsp; schools from N schools:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=my_data ; by school;run;&lt;/P&gt;
&lt;P&gt;data my_data ;set my_data ;&lt;BR /&gt;by school;&lt;BR /&gt;/*Placing a random number for school and for students*/&lt;BR /&gt;retain&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;uSchool&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;0;&lt;BR /&gt;if first.school then&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;uschool&lt;/STRONG&gt;=ranuni(12222154);&lt;BR /&gt;&lt;STRONG&gt;ustudent&lt;/STRONG&gt;=ranuni(8744);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;ctreate table&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;distinct_schools&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as&lt;/P&gt;
&lt;P&gt;select distinict school,&lt;STRONG&gt;uschool&lt;/STRONG&gt;,stratum1,&amp;nbsp;stratum2 ,&amp;nbsp;stratum3,&amp;nbsp;stratum4&lt;/P&gt;
&lt;P&gt;from my_data;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=&lt;STRONG&gt;distinct_schools&lt;/STRONG&gt;&amp;nbsp;; by&amp;nbsp;&lt;STRONG&gt;uschool;&lt;/STRONG&gt;run;&lt;/P&gt;
&lt;P&gt;proc surveyselect data=&lt;STRONG&gt;distinct_schools&lt;/STRONG&gt;&amp;nbsp; out=&lt;STRONG&gt;K_schools&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;outsorting=k_schools_sort&lt;/P&gt;
&lt;P&gt;method=&lt;STRONG&gt;srs&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sampsize=&lt;STRONG&gt;60&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;seed=1234;&lt;/P&gt;
&lt;P&gt;control&amp;nbsp;stratum2 stratum3&amp;nbsp; stratum4;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;2- and perform another sample,&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;sample 4 students from the 2 levels of stratum1 and at the third level we will sample 5 students&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;of 4 ostudents from the K schools for the two tiers separately.&lt;BR /&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Students_frame&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;as&lt;/P&gt;
&lt;P&gt;select a.school,b.*&lt;/P&gt;
&lt;P&gt;from&amp;nbsp;&lt;STRONG&gt;distinct_schools&lt;/STRONG&gt;&amp;nbsp; as a left join my_data as b&lt;/P&gt;
&lt;P&gt;on a.school=b.school;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=&lt;STRONG&gt;Students_frame;&lt;/STRONG&gt;&amp;nbsp;by&amp;nbsp; uSchool&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ustudent&amp;nbsp;stratum1&lt;/STRONG&gt;;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc surveyselect data=&lt;STRONG&gt;Students_frame&lt;/STRONG&gt;out=&lt;STRONG&gt;Students_sample&lt;/STRONG&gt;&amp;nbsp;outsorting=&lt;STRONG&gt;sort_Students_sample&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;method=&lt;STRONG&gt;srs&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sampsize=&lt;STRONG&gt;( 4 4 5)&amp;nbsp;&lt;/STRONG&gt;seed=323161;&lt;/P&gt;
&lt;P&gt;strata uschool&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;stratum1&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;control&amp;nbsp;stratum2 stratum3&amp;nbsp; stratum4;&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;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Do you have another suggestion that you do the sampling in one stroke and not split in two?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 16:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sampiling-studetns-from-K-out-of-N-schools-by-3-stratum-leves/m-p/610770#M177923</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-10T16:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: sampiling studetns from K out of N schools by 3 stratum leves?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sampiling-studetns-from-K-out-of-N-schools-by-3-stratum-leves/m-p/611024#M178032</link>
      <description>&lt;P&gt;One way to select a first-stage sample of schools is to use the&amp;nbsp;&lt;A href="https://go.documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_surveyselect_syntax05.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en" target="_self"&gt;CLUSTER&lt;/A&gt;&amp;nbsp;statement in PROC SURVEYSELECT.&lt;/P&gt;
&lt;P&gt;For example,&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=my_data out=SchoolSample sampsize=K seed=1234;
   cluster school;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is necessary to invoke PROC SURVEYSELECT separately for each stage of selection. For your example, you can select the first-stage sample of schools from DATA=my_data, and then select the second-stage sample of students from the selected schools (DATA=SchoolSample).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like your SURVEYSELECT code includes a&amp;nbsp;&lt;A href="https://go.documentation.sas.com/?docsetId=statug&amp;amp;docsetVersion=15.1&amp;amp;docsetTarget=statug_surveyselect_syntax02.htm&amp;amp;locale=en" target="_self"&gt;CONTROL&lt;/A&gt;&amp;nbsp;statement together with METHOD=SRS. This will produce an error because CONTROL sorting applies only to systematic and sequential selection methods.&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 14:52:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sampiling-studetns-from-K-out-of-N-schools-by-3-stratum-leves/m-p/611024#M178032</guid>
      <dc:creator>Watts</dc:creator>
      <dc:date>2019-12-11T14:52:28Z</dc:date>
    </item>
  </channel>
</rss>

