<?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: Weighted random stratified sampling with replacement in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Weighted-random-stratified-sampling-with-replacement/m-p/545210#M27277</link>
    <description>&lt;P&gt;I ended up going rather 'manually'.&amp;nbsp; For now it will suffice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data stress;&lt;BR /&gt;set stress;&lt;BR /&gt;if Tolerance = 'D' then SampSize= 10;&lt;BR /&gt;else if Tolerance = 'I' then SampSize= 20;&lt;BR /&gt;else if Tolerance = 'S' then SampSize= 30;&lt;BR /&gt;else if Tolerance = 'N' then SampSize= 40;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data = stress;by Tolerance;run;&lt;BR /&gt;proc sql;&lt;BR /&gt;select distinct SampSize into:SampSize separated by ' ' from Stress;&lt;BR /&gt;quit;&lt;BR /&gt;proc surveyselect data=stress method=urs n=(&amp;amp;SampSize.) out=StressSample outhits;&lt;BR /&gt;strata Tolerance;&lt;BR /&gt;run;&lt;BR /&gt;proc freq data = StressSample;&lt;BR /&gt;tables Tolerance;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2019 13:06:45 GMT</pubDate>
    <dc:creator>Santelle</dc:creator>
    <dc:date>2019-03-22T13:06:45Z</dc:date>
    <item>
      <title>Weighted random stratified sampling with replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Weighted-random-stratified-sampling-with-replacement/m-p/545195#M27276</link>
      <description>&lt;P&gt;My sample data is not representative of my population, so I'm trying to draw a random sample according to predefined proportions.&amp;nbsp; In effect, some groups will have to be over sampled with replacement in order to reach its required proportion, while other groups will have enough observations to sample from.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a simple equivalent example.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data stress;&lt;BR /&gt;input ID 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33&lt;BR /&gt;RecHR 35-37 TimeMin 39-40 TimeSec 42-43&lt;BR /&gt;Tolerance $ 45;&lt;BR /&gt;datalines;&lt;BR /&gt;2458 Murray, W 72 185 128 12 38 D&lt;BR /&gt;2462 Almers, C 68 171 133 10 5 I&lt;BR /&gt;2501 Bonaventure, T 78 177 139 11 13 I&lt;BR /&gt;2523 Johnson, R 69 162 114 9 42 S&lt;BR /&gt;2539 LaMance, K 75 168 141 11 46 D&lt;BR /&gt;2544 Jones, M 79 187 136 12 26 N&lt;BR /&gt;2552 Reberson, P 69 158 139 15 41 D&lt;BR /&gt;2555 King, E 70 167 122 13 13 I&lt;BR /&gt;2563 Pitts, D 71 159 116 10 22 S&lt;BR /&gt;2568 Eberhardt, S 72 182 122 16 49 N&lt;BR /&gt;2571 Nunnelly, A 65 181 141 15 2 I&lt;BR /&gt;2572 Oberon, M 74 177 138 12 11 D&lt;BR /&gt;2574 Peterson, V 80 164 137 14 9 D&lt;BR /&gt;2575 Quigley, M 74 152 113 11 26 I&lt;BR /&gt;2578 Cameron, L 75 158 108 14 27 I&lt;BR /&gt;2579 Underwood, K 72 165 127 13 19 S&lt;BR /&gt;2584 Takahashi, Y 76 163 135 16 7 D&lt;BR /&gt;2586 Derber, B 68 176 119 17 35 N&lt;BR /&gt;2588 Ivan, H 70 182 126 15 41 N&lt;BR /&gt;2589 Wilcox, E 78 189 138 14 57 I&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the end I'd like to have 10% of my data to be for Tolerance = 'D', 20% to be for Tolerance = 'I', and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data stress;&lt;BR /&gt;set stress;&lt;BR /&gt;if Tolerance = 'D' then Proportion = 0.1;&lt;BR /&gt;else if Tolerance = 'I' then Proportion = 0.2;&lt;BR /&gt;else if Tolerance = 'S' then Proportion = 0.3;&lt;BR /&gt;else if Tolerance = 'N' then Proportion = 0.4;&lt;BR /&gt;run;&lt;BR /&gt;proc freq data = stress;&lt;BR /&gt;tables Tolerance;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what I've tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sort data = stress;by Tolerance;run;&lt;BR /&gt;proc surveyselect data=stress&lt;BR /&gt;method = urs&lt;BR /&gt;seed=12345&lt;BR /&gt;sampsize = 1000&lt;BR /&gt;out=StressStample1&lt;BR /&gt;outhits&lt;BR /&gt;;&lt;BR /&gt;id _all_;&lt;BR /&gt;strata Tolerance;&lt;BR /&gt;run;&lt;BR /&gt;proc surveyselect data=stress&lt;BR /&gt;method=PPS_WR&lt;BR /&gt;seed=12345&lt;BR /&gt;sampsize=1000&lt;BR /&gt;out=StressSample2&lt;BR /&gt;outhits&lt;BR /&gt;;&lt;BR /&gt;id _all_;&lt;BR /&gt;strata Tolerance;&lt;BR /&gt;size Proportion;&lt;BR /&gt;run;&lt;BR /&gt;proc freq data = StressStample1;&lt;BR /&gt;tables Tolerance;&lt;BR /&gt;run;&lt;BR /&gt;proc freq data = StressSample2;&lt;BR /&gt;tables Tolerance;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanx in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 12:14:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Weighted-random-stratified-sampling-with-replacement/m-p/545195#M27276</guid>
      <dc:creator>Santelle</dc:creator>
      <dc:date>2019-03-22T12:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted random stratified sampling with replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Weighted-random-stratified-sampling-with-replacement/m-p/545210#M27277</link>
      <description>&lt;P&gt;I ended up going rather 'manually'.&amp;nbsp; For now it will suffice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data stress;&lt;BR /&gt;set stress;&lt;BR /&gt;if Tolerance = 'D' then SampSize= 10;&lt;BR /&gt;else if Tolerance = 'I' then SampSize= 20;&lt;BR /&gt;else if Tolerance = 'S' then SampSize= 30;&lt;BR /&gt;else if Tolerance = 'N' then SampSize= 40;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data = stress;by Tolerance;run;&lt;BR /&gt;proc sql;&lt;BR /&gt;select distinct SampSize into:SampSize separated by ' ' from Stress;&lt;BR /&gt;quit;&lt;BR /&gt;proc surveyselect data=stress method=urs n=(&amp;amp;SampSize.) out=StressSample outhits;&lt;BR /&gt;strata Tolerance;&lt;BR /&gt;run;&lt;BR /&gt;proc freq data = StressSample;&lt;BR /&gt;tables Tolerance;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 13:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Weighted-random-stratified-sampling-with-replacement/m-p/545210#M27277</guid>
      <dc:creator>Santelle</dc:creator>
      <dc:date>2019-03-22T13:06:45Z</dc:date>
    </item>
  </channel>
</rss>

