<?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/609668#M177505</link>
    <description>&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; K out of N&lt;/STRONG&gt; schools in distict school&lt;BR /&gt;And in each out of the&amp;nbsp;&lt;STRONG&gt; K&lt;/STRONG&gt; school, I want to sample to each level of the sample &lt;STRONG&gt;stratum1&lt;/STRONG&gt;, a different number of students&lt;BR /&gt;When at&lt;STRONG&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;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;STRONG&gt;uSchool&lt;/STRONG&gt; 0;&lt;BR /&gt;if first.school then &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;STRONG&gt;distinct_schools&lt;/STRONG&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; outsorting=k_schools_sort&lt;/P&gt;&lt;P&gt;method=&lt;STRONG&gt;srs&lt;/STRONG&gt; sampsize=&lt;STRONG&gt;60&lt;/STRONG&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;STRONG&gt;Students_frame &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;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; sampsize=&lt;STRONG&gt;( 4 4 5)&amp;nbsp;&lt;/STRONG&gt;seed=323161;&lt;/P&gt;&lt;P&gt;strata uschool &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;</description>
    <pubDate>Thu, 05 Dec 2019 13:00:02 GMT</pubDate>
    <dc:creator>Ash_75</dc:creator>
    <dc:date>2019-12-05T13:00:02Z</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/609668#M177505</link>
      <description>&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; K out of N&lt;/STRONG&gt; schools in distict school&lt;BR /&gt;And in each out of the&amp;nbsp;&lt;STRONG&gt; K&lt;/STRONG&gt; school, I want to sample to each level of the sample &lt;STRONG&gt;stratum1&lt;/STRONG&gt;, a different number of students&lt;BR /&gt;When at&lt;STRONG&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;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;STRONG&gt;uSchool&lt;/STRONG&gt; 0;&lt;BR /&gt;if first.school then &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;STRONG&gt;distinct_schools&lt;/STRONG&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; outsorting=k_schools_sort&lt;/P&gt;&lt;P&gt;method=&lt;STRONG&gt;srs&lt;/STRONG&gt; sampsize=&lt;STRONG&gt;60&lt;/STRONG&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;STRONG&gt;Students_frame &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;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; sampsize=&lt;STRONG&gt;( 4 4 5)&amp;nbsp;&lt;/STRONG&gt;seed=323161;&lt;/P&gt;&lt;P&gt;strata uschool &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;</description>
      <pubDate>Thu, 05 Dec 2019 13:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sampiling-studetns-from-K-out-of-N-schools-by-3-stratum-leves/m-p/609668#M177505</guid>
      <dc:creator>Ash_75</dc:creator>
      <dc:date>2019-12-05T13:00:02Z</dc:date>
    </item>
  </channel>
</rss>

