<?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: Selecting a weighted sample without replacement in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731407#M35494</link>
    <description>&lt;P&gt;Here is an example using the certsize option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let sampSize=12;

proc sql;
select sum(weight)/&amp;amp;sampSize. into :certSize
from one;
quit;

proc surveyselect data=one out=two seed=868765
    method=pps sampsize=&amp;amp;sampSize. certsize=&amp;amp;certSize.; 
size weight;
id Unit_id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which selects&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1617650383994.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56928iEE5C192E6D4DF17A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_0-1617650383994.png" alt="PGStats_0-1617650383994.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Note the presence of variable Certain indicating selection with certainty.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Apr 2021 19:22:39 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2021-04-05T19:22:39Z</dc:date>
    <item>
      <title>Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731349#M35479</link>
      <description>&lt;P&gt;I have the following example data:&lt;/P&gt;&lt;PRE&gt;data one;
  input Unit_ID weight @@;
  datalines;
 1  237.18    2 567.89    3  118.50    4   74.38     5 1287.23     6  258.10
 7  325.36    8 218.38    9 1670.80   10  134.71    11 2020.70    12   47.80
13 1183.45   14 330.54   15  780.10   16  895.80    17  620.10    18  420.18
19  979.66   20 810.25   21  670.85   22  314.58    23   87.50    24 1893.40
25  753.30   26 540.65   27 2580.35   28  230.56    29  185.60    30  688.43
31  505.14   32 205.48   33  650.42   34 1348.34    35   30.50    36 2214.80
37  940.35   38 217.85   39  142.90   40  806.90    41  560.72
;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Now I want to select 12 records based on the weight variable. So, a higher weight should result in a higher probability that this&lt;BR /&gt;record ends up in my sample. Once a record is selected, that record should not be selected again.&lt;BR /&gt;&lt;BR /&gt;I've looked into proc surveyselect but I'm unable to figure out if this is the right proc to use, and if applicable, how to use it.&lt;BR /&gt;&lt;BR /&gt;Can anyone help me with this? I would like to use a standard proc that is available in SAS.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Berry&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 13:42:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731349#M35479</guid>
      <dc:creator>BerryH</dc:creator>
      <dc:date>2021-04-05T13:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731354#M35480</link>
      <description>&lt;P&gt;I would think that this is exactly what PROC SURVEYSELECT does well, you can use the options METHOD=PPS and the SIZE statement in order to create samples whose probability is proportional to size (in your case the variable WEIGHT) and without replacement. Do you agree?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please, in the future, do not type text in code boxes. Text goes outside code boxes. Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 13:39:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731354#M35480</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-05T13:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731360#M35481</link>
      <description>&lt;P&gt;Indeed I expected that proc surveyselect would do the job. However, I ran into this problem when using it:&amp;nbsp;&lt;A href="https://support.sas.com/kb/23/759.html" target="_blank"&gt;https://support.sas.com/kb/23/759.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To summarize, I can select 11 samples, but not 12 because proc surveyselect throws an error. Also, I'm not sure about the proposed workarounds that are given.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So perhaps I don't understand what proc surveyselect is supposed to do and/or I'm using it incorrectly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Berry&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 13:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731360#M35481</guid>
      <dc:creator>BerryH</dc:creator>
      <dc:date>2021-04-05T13:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731362#M35482</link>
      <description>&lt;P&gt;So in this case, you already have the answer.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 14:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731362#M35482</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-05T14:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731371#M35486</link>
      <description>&lt;P&gt;The note does not help me in getting the 12 samples because it proposes solutions that I can't use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Use minimum replacement (PPS sequential).&lt;/P&gt;&lt;P&gt;I don't want to use replacement, it should be a sample without replacement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Adjusting size measures by specifying certsize or maxsize options.&lt;/P&gt;&lt;P&gt;I don't want to adjust size measures. The sizes (weights) in the data are the sizes that should be used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any alternative proc to get the 12 samples that I need?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 14:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731371#M35486</guid>
      <dc:creator>BerryH</dc:creator>
      <dc:date>2021-04-05T14:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731374#M35487</link>
      <description>&lt;P&gt;You are now out of my range of experience, as I have never had to face this situation.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 15:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731374#M35487</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-05T15:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731378#M35488</link>
      <description>&lt;P&gt;AS an absolute minimum when declaring code doesn't do what you want : &lt;STRONG&gt;Include the code.&lt;/STRONG&gt;&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;Select as many as the data allows.&lt;/P&gt;
&lt;P&gt;Reduce the data to the not selected.&lt;/P&gt;
&lt;P&gt;Select additional records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: you will need to spend some time creating sampling weights because the second (or subsequent sets) depend on the prior selections.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or get a bigger initial sample.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 15:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731378#M35488</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-05T15:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731389#M35491</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;In addition to adjusting the size measures or selecting the sample "with minimum replacement," another possible approach in this situation is to include the "large" units with certainty (automatically, with selection probability=1). This is frequently done in practice. You can do this in PROC SURVEYSELECT by using the&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_surveyselect_syntax01.htm&amp;amp;docsetVersion=15.2&amp;amp;locale=en#statug.surveyselect.selectcertsize" target="_self"&gt;CERTSIZE=&lt;/A&gt; option or the &lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_surveyselect_syntax01.htm&amp;amp;docsetVersion=15.2&amp;amp;locale=en#statug.surveyselect.selectcertsizep" target="_self"&gt;CERTSIZE=P=&lt;/A&gt; option.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 05 Apr 2021 15:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731389#M35491</guid>
      <dc:creator>Watts</dc:creator>
      <dc:date>2021-04-05T15:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731397#M35492</link>
      <description>&lt;P&gt;The reason why weighted selection without replacement cannot be done when some of the relative weigths are greater than 1/sampsize is quite simple. The goal of the sampling method is to give a sampling probability of weight/sum(weight) to every sampling unit. But since the unit can only appear once in the sample (because replacement is not allowed), the maximum sampling probability of any unit is 1/sampsize. Thus, the goal is mathematically impossible to achieve for units with relative weights greater than 1/sampsize.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 17:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731397#M35492</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-04-05T17:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731399#M35493</link>
      <description>&lt;P&gt;Well, here is something that does, well, something.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;EDIT: It turns out that the "something" is NOT what I said it might be.&amp;nbsp; See the post by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;for an excellent proof of this.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I create a new weight as the product of a uniform random variate and the weight variable in the dataset divided by the sum of all the weights, sort the dataset in descending order by the new variable, and then select the first 12 id numbers in the sorted dataset..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  input Unit_ID weight @@;
  datalines;
 1  237.18    2 567.89    3  118.50    4   74.38     5 1287.23     6  258.10
 7  325.36    8 218.38    9 1670.80   10  134.71    11 2020.70    12   47.80
13 1183.45   14 330.54   15  780.10   16  895.80    17  620.10    18  420.18
19  979.66   20 810.25   21  670.85   22  314.58    23   87.50    24 1893.40
25  753.30   26 540.65   27 2580.35   28  230.56    29  185.60    30  688.43
31  505.14   32 205.48   33  650.42   34 1348.34    35   30.50    36 2214.80
37  940.35   38 217.85   39  142.90   40  806.90    41  560.72
;
data two;
set one;
call streaminit(452021);
ranno1=rand('uniform');
ranno2=ranno1*weight;
run;

proc means data=one noprint;
var weight;
output out=totsamp sum=sum;
run;

data combined;
 if _n_=1 then set totsamp;
 set two;
 drop _type_ _freq_;
 relsize=ranno2/sum;
 run;

proc sort data=combined out=three;
by descending relsize;
run;

data four;
set three;
if _n_&amp;lt;=12;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am not sure about the optimality of this method at all.&amp;nbsp; Relsize is a product of the (assumed) probability of selection (=ranno1) and the proportion of the total weight each ID contributes (=weight/sum).&amp;nbsp; The first 12 are then the most likely IDs to be selected, and the procedure is such that once an ID is selected, it cannot be selected again.&amp;nbsp; I suppose iteratively reweighting would be better, which would loop through, selecting the ID with the largest relsize, removing it from dataset one, recalculating the total weight, and the proportion of the total weight, multiplying this by the random number, resorting, selecting the ID with the largest relsize under this condition, removing it, and going through this until 12 IDs had been selected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 12:15:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731399#M35493</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2021-04-06T12:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731407#M35494</link>
      <description>&lt;P&gt;Here is an example using the certsize option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let sampSize=12;

proc sql;
select sum(weight)/&amp;amp;sampSize. into :certSize
from one;
quit;

proc surveyselect data=one out=two seed=868765
    method=pps sampsize=&amp;amp;sampSize. certsize=&amp;amp;certSize.; 
size weight;
id Unit_id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which selects&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1617650383994.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56928iEE5C192E6D4DF17A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_0-1617650383994.png" alt="PGStats_0-1617650383994.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Note the presence of variable Certain indicating selection with certainty.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 19:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731407#M35494</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-04-05T19:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731409#M35495</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;I would like to use a standard proc that is available in SAS.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Do you have access to PROC IML?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 19:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731409#M35495</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-04-05T19:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731482#M35496</link>
      <description>&lt;P&gt;About that &lt;EM&gt;Something method,&lt;/EM&gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15363"&gt;@SteveDenham&lt;/a&gt;, I was curious....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suppose that we want to choose a sample of one from a set of two units with sampling weights P1 and P2, such that P1+P2 = 1.&lt;/P&gt;
&lt;P&gt;Now, if I understand your sampling method, we generate two uniform random numbers X1 and X2 and sample unit 1 if X1*P1 &amp;gt; X2*P2. What we would want is that the probability of choosing unit 1,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P(1) = P1/(P1+P2) = P1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rearranging terms, the probability P(1) can be expressed&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P(1) = P( X2/(X1+X2) &amp;lt; P1 )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which is the PDF of the random quantity X2/(X1+X2) at P1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's look at that PDF for r = X2/(X1+X2), with X1 and X2 uniform.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
do i = 1 to 100000;
    x1 = rand("uniform");
    x2 = rand("uniform");
    r = x2 / (x2+x1);
    output;
    end;
keep r;
run;

proc univariate data=test noprint;
cdfplot / vscale=proportion href=.25 .5 .75 vref=.25 .5 .75;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1617662604855.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56971iE7075AB693B6DDE9/image-size/large?v=v2&amp;amp;px=999" role="button" title="PGStats_0-1617662604855.png" alt="PGStats_0-1617662604855.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As we can see, there is only one non-trivial value of r where P(1) = P1, and that is when r=0.5, i.e. for equal probability sampling.&lt;/P&gt;
&lt;P&gt;So, as intuitively appealing as this method is, it will not generate the expected sampling probabilities.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 22:58:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731482#M35496</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-04-05T22:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731523#M35500</link>
      <description>&lt;P&gt;Unfortunately not.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 07:30:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731523#M35500</guid>
      <dc:creator>BerryH</dc:creator>
      <dc:date>2021-04-06T07:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731525#M35501</link>
      <description>&lt;P&gt;If you read the posts above, you see code that is relevant for my question.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 07:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731525#M35501</guid>
      <dc:creator>BerryH</dc:creator>
      <dc:date>2021-04-06T07:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731527#M35502</link>
      <description>&lt;P&gt;Thank you for the example. However, I don't understand why it is necessary to use the certsize option. The following code in Python does exactly what I want. I hoped that something similar would exist for SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-04-05 at 20.47.07.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56977i7840E58229AAB3B5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-04-05 at 20.47.07.png" alt="Screenshot 2021-04-05 at 20.47.07.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 07:35:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731527#M35502</guid>
      <dc:creator>BerryH</dc:creator>
      <dc:date>2021-04-06T07:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731573#M35507</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;.&amp;nbsp; That is a great job.&amp;nbsp; I'll go back and edit my post to note that the method does not do what I thought it might.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 12:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731573#M35507</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2021-04-06T12:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731585#M35508</link>
      <description>&lt;P&gt;Not really an expert on PROC SURVEYSELECT but if you wanted to generate a random value from 1 to N with weighted probabilities use the RAND('table',....) function.&amp;nbsp; So to convert your weights into percentages divide by the sum of the weigths.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To sample without replacement you could try adjusting the percentages removing the sampled case.&amp;nbsp; I am not sure if this is mathematically correct, but it should at least lead to a fairly close approximation of random.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data one;
  input Unit_ID weight @@;
  datalines;
 1  237.18    2 567.89    3  118.50    4   74.38     5 1287.23     6  258.10
 7  325.36    8 218.38    9 1670.80   10  134.71    11 2020.70    12   47.80
13 1183.45   14 330.54   15  780.10   16  895.80    17  620.10    18  420.18
19  979.66   20 810.25   21  670.85   22  314.58    23   87.50    24 1893.40
25  753.30   26 540.65   27 2580.35   28  230.56    29  185.60    30  688.43
31  505.14   32 205.48   33  650.42   34 1348.34    35   30.50    36 2214.80
37  940.35   38 217.85   39  142.90   40  806.90    41  560.72
;

proc sql noprint;
select count(*) into :nobs trimmed from one;
quit;


%let samp=13;
data sample;
* Load the orginial weights ;
* Sum weights ;
  if _n_=1 then do;
     TOTAL_WT=0;
     do i=1 to &amp;amp;nobs;
       set one point=i  ;
       array wt [1:&amp;amp;nobs] _temporary_;
       wt[i]=weight;
       total_wt + weight ;
     end;
  end;
  do choice=1 to &amp;amp;samp;
* Re-calculate percentages ;
    array pct [1:&amp;amp;nobs] _temporary_;
    do i=1 to &amp;amp;nobs;
      pct[i] = wt[i] / total_wt ;
    end;
    j=rand('table',of pct[*]);
    if j in (1:&amp;amp;nobs) then do;
      set one point=j;
      output;
      total_wt+-wt[j];
      wt[j]=0;
    end;
  end;
stop;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 13:16:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731585#M35508</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-06T13:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731586#M35509</link>
      <description>Maybe I misunderstand something about your question.&lt;BR /&gt;Why not PROC SORT your dataset BY weight and pick up the obs which have maximize 12 of weight  ?</description>
      <pubDate>Tue, 06 Apr 2021 13:22:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731586#M35509</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-04-06T13:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a weighted sample without replacement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731672#M35516</link>
      <description>&lt;P&gt;I couldn't find a detailed explanation of the selection method in the dataframe.sample documentation. But I suspect that the .sample method does something very similar to surveyselect with the certsize option when required. SAS gives you a bit more flexibility with its option, and the opportunity to realize that your sample will not (can not) exhibit sampling probabilities greater than 1/sampsize for any unit, unless you allow replacement.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 19:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Selecting-a-weighted-sample-without-replacement/m-p/731672#M35516</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-04-06T19:08:14Z</dc:date>
    </item>
  </channel>
</rss>

