<?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: Randomly select  3 rows with condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/916643#M361027</link>
    <description>&lt;P&gt;Or equivalently,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyselect data=have out=temp seed=123 sampsize=3 noprint;
samplingunit dept_no;
proc surveyselect data=temp out=want seed=123 sampsize=1 noprint;
strata dept_no;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note: May be a bit faster if you have more distinct depts than emp by dept.&lt;/P&gt;
&lt;P&gt;Note: Sorting is implied in the first selection step.&lt;/P&gt;</description>
    <pubDate>Sat, 17 Feb 2024 22:26:55 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2024-02-17T22:26:55Z</dc:date>
    <item>
      <title>Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/916617#M361012</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&lt;EM&gt; I want to select randomly&amp;nbsp;3 rows from data set have&amp;nbsp; with the following condition-&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Not select a department (dept_no) more than once&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;For example:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;1 10&lt;BR /&gt;2 10&lt;BR /&gt;3 20&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Is not meeting the criteria because dept_no 10 appear more than once&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
input emp_no dept_no;
cards;
1 10
2 10
3 20
4 30
5 20
6 40
7 10
8 90
9 20
10 30
;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the way to do it with teradata code but I want to ask how to do it with sas code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select *
from have
qualify rank() over(partition by dept_no ordr by dept_no)=1
sample 3&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Feb 2024 08:11:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/916617#M361012</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-02-17T08:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/916621#M361016</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
input emp_no dept_no;
cards;
1 10
2 10
3 20
4 30
5 20
6 40
7 10
8 90
9 20
10 30
;
Run;

proc sort data=have;by dept_no;run;
proc surveyselect data=have out=temp seed=123 sampsize=1 noprint outrandom;
strata dept_no;
run;
proc surveyselect data=temp out=want seed=123 sampsize=3 noprint outrandom;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Feb 2024 11:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/916621#M361016</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-02-17T11:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/916643#M361027</link>
      <description>&lt;P&gt;Or equivalently,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyselect data=have out=temp seed=123 sampsize=3 noprint;
samplingunit dept_no;
proc surveyselect data=temp out=want seed=123 sampsize=1 noprint;
strata dept_no;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note: May be a bit faster if you have more distinct depts than emp by dept.&lt;/P&gt;
&lt;P&gt;Note: Sorting is implied in the first selection step.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 22:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/916643#M361027</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2024-02-17T22:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/916649#M361030</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyselect data=have out=temp seed=123 sampsize=3 noprint;
samplingunit dept_no;
proc surveyselect data=temp out=want seed=123 sampsize=1 noprint;
strata dept_no;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I've never used proc surveyselect, and haven't thought about sampling for a long time, so I am going to venture beyond my usual competencies.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the first proc surveyselect above, are all dept_no's equally likely to be selected, regardless of size?&amp;nbsp; &amp;nbsp;&amp;nbsp;I suspect that is the case - I appended another 990 observations with&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;"dept_no=30"&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; (department 30 was not originally selected), used the same seed, and got the same result, i.e. department 30 did not get selected, even though it was 99% of my contrived sample.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the OP's request, I would have assumed that all obs should be equally likely, subject to the constraint (i.e. they should come from 3 distinct departments).&amp;nbsp; Which in turn makes me think that the first surveyselect above should rendomly select departments weighted proportionate to their frequency.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could this be the case?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Feb 2024 14:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/916649#M361030</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-02-18T14:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917272#M361319</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In the OP's request, I would have assumed that all obs should be equally likely, subject to the constraint (i.e. they should come from 3 distinct departments).&amp;nbsp; Which in turn makes me think that the first surveyselect above should rendomly select departments weighted proportionate to their frequency.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is a good point as it addresses the question what &lt;EM&gt;probability distribution&lt;/EM&gt; should govern the "random" selection. There are 68 (out of &lt;FONT face="courier new,courier"&gt;comb(10,3)=120&lt;/FONT&gt;) different selections of three employee numbers (EMP_NO) satisfying the constraint. Virtually any generic probability distribution on this finite set could be regarded as a solution. While the OP's Teradata code determines a distribution, it is not clear whether this choice was based on statistical considerations or just code availability.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A different distribution would assign probability 1/68 to each eligible "triple" of EMP_NOs. PG's code, however, creates a distribution with equal probability (of 1/10) for each eligible triple of &lt;EM&gt;DEPT&lt;/EM&gt;_NOs (and in particular&amp;nbsp;equal probabilities [of 0.6] for each department to occur in the selection). There are many distributions with this characteristic. Yet another class of distributions would feature equal probabilities (of 0.3) for each EMP_NO. One of these could be obtained by adding the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_surveyselect_syntax05.htm#statug.surveyselect.selectclusterpps" target="_blank" rel="noopener"&gt;PPS option&lt;/A&gt; to the SAMPLINGUNIT statement in PG's code (thus implementing your idea of selecting "departments weighted proportionate to their frequency"). I think in general it depends on the input data whether&amp;nbsp;equal probabilities for each EMP_NO can be achieved.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 22:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917272#M361319</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-02-21T22:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917718#M361507</link>
      <description>&lt;P&gt;Some questions please-&lt;/P&gt;
&lt;P&gt;1-What is the meaning of seed=123.Why did you choose value 123 and not other value? will result be different if you change seed value?&lt;/P&gt;
&lt;P&gt;Should we always write seed=123 or it depends on out task?&lt;/P&gt;
&lt;P&gt;2- You wrote&amp;nbsp; sampzise=1. Is it equivalent to write n=1?&lt;/P&gt;
&lt;P&gt;3-Yuo didnt write method=srs. IS it because the default is srs?&lt;/P&gt;
&lt;P&gt;4-What is the meaning of outrandom? Why did you add this word to code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2024 07:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917718#M361507</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-02-24T07:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917721#M361510</link>
      <description>&lt;P&gt;In your code you first choose 3 departments and then one observarion of each of them.&lt;/P&gt;
&lt;P&gt;What is the difference between yor code and following code?&lt;/P&gt;
&lt;P&gt;You use&amp;nbsp; "samplingunit"&amp;nbsp; and here I use "&lt;CODE class=" language-sas"&gt;cluster"&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyselect data=Haveout=temp n=3 seed=123;
cluster dept_no;
Run;

proc surveyselect data=temp out=want n=1 seed=123;
strata dept_no;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2024 09:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917721#M361510</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-02-24T09:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917738#M361517</link>
      <description>&lt;P&gt;"samplingunit"&amp;nbsp; and "&lt;CODE class="  language-sas"&gt;cluster"&lt;/CODE&gt; are synonyms, see the &lt;A href="https://documentation.sas.com/doc/en/statug/15.2/statug_surveyselect_syntax05.htm" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;. &lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2024 20:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917738#M361517</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2024-02-24T20:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917746#M361520</link>
      <description>&lt;P&gt;Here is a program that randomly selects 3 obs from among (up to) 10 departments, such that each obs comes from a different department.&amp;nbsp; &lt;STRIKE&gt;The probability of selecting from a given department is proportional to the department's size.&amp;nbsp; &lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;Editted Note:&lt;/STRONG&gt;&amp;nbsp; At each sample selection, the&amp;nbsp;probability of selecting from a given department is proportional to the department's size (&lt;EM&gt;&lt;STRONG&gt;relative to the total of available departments&lt;/STRONG&gt;&lt;/EM&gt;).&amp;nbsp; But because of the constraint, at each obs there is a reduced number of possible departments - thereby changing the probability of selection among remaining departments.&amp;nbsp; So the probability of being among the 3 obs is NOT proportional to the size of the department vs all original departments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After a given employee is selected, that department's probability of selection is set to zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edited note:&amp;nbsp; I've moved the assignment of a _seed value from inside to outside of the "do obs=1 to &amp;amp;sampsize" loop, as per&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;'s comment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I've added a test dataset have, containing dept_no 1 through dept_no 10, with 4,8,12,...,40 employees respectively.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  do dept_no=1 to 10;
    do i=1 to 4*dept_no;
      emp_id=dept_no+i/100;
      format dept_no z2.  emp_id z5.2;
      drop i;
      output;
    end;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let n_dep=10;    /*Provide for up to this many departments, may be larger than actual department count*/
%let sampsize=3;  /*N of employees to select, each from a different department */

data want (drop=_: d);
  set have end=end_of_have;

  length dept_size 8;
  if _n_=1 then do;
    declare hash h();    /*Department Size, plus One random obs per department */
      h.definekey('dept_no');
      h.definedata('dept_no','dept_size','_emp_no_samp','_rnum_samp');
      h.definedone();
    declare hiter hi ('h');
  end;

  _rnum_emp=ranuni(109581508);     /*Randum num for this employee */

  if h.find()^=0 then call missing(dept_size,_rnum_samp);
  dept_size = sum(dept_size,1);

  if _rnum_emp &amp;gt; _rnum_samp then do;  /* Keep the employee with the highest random number */
    _rnum_samp   = _rnum_emp;
    _emp_no_samp = emp_no;
  end;
  h.replace();

  _n_avail+1;

  if end_of_have;

  array dept_share {&amp;amp;n_dep} _temporary_ (&amp;amp;n_dep*0) ;
  array dept       {&amp;amp;n_dep} _temporary_  ;

  do obs=1 to &amp;amp;sampsize while (_n_avail&amp;gt;0);
    do d=1 by 1 while (hi.next()=0);
      dept_share{d}=dept_size/_n_avail;
      dept{d}=dept_no;
    end;

    _seed=508333952;
    call rantbl(_seed,of dept_share{*},d);  /* Randomly choose department, proportional to size */
    h.find(key:dept{d});
    emp_no=_emp_no_samp;
    output;

    _n_avail = _n_avail - dept_size;        /* Remove this department from furthr sampling */
    dept_size=0;
    h.replace();
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 04:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917746#M361520</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-02-26T04:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917766#M361527</link>
      <description>You asked too many questions.&lt;BR /&gt;1-What is the meaning of seed=123.Why did you choose value 123 and not other value? will result be different if you change seed value?&lt;BR /&gt;/*******&lt;BR /&gt;seed=123 is a random seed, you could select any number, like 321 or 1 ...&lt;BR /&gt;Yes. If you changed this random seed, you will got different result.&lt;BR /&gt;Set a random seed by seed= is to make sure the result could be reproduced.&lt;BR /&gt;********/&lt;BR /&gt;&lt;BR /&gt;Should we always write seed=123 or it depends on out task?&lt;BR /&gt;/***&lt;BR /&gt;No. You could write any number you want.&lt;BR /&gt;******/&lt;BR /&gt;2- You wrote  sampzise=1. Is it equivalent to write n=1?&lt;BR /&gt;/**&lt;BR /&gt;Yes.&lt;BR /&gt;**/&lt;BR /&gt;&lt;BR /&gt;3-Yuo didnt write method=srs. IS it because the default is srs?&lt;BR /&gt;/**&lt;BR /&gt;Yes. You are correct.&lt;BR /&gt;**/&lt;BR /&gt;&lt;BR /&gt;4-What is the meaning of outrandom? Why did you add this word to code?&lt;BR /&gt;/****&lt;BR /&gt;That means randomize the result.&lt;BR /&gt;If your result was 2,5,1,7,9 (the order is the same with dataset), using OUTRANDOM would randomly order it,like  9,1,5,7,2&lt;BR /&gt;****/</description>
      <pubDate>Sun, 25 Feb 2024 08:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917766#M361527</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-02-25T08:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917834#M361544</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you. This is a nice algorithm. I assume that you intended to set the second random seed (&lt;FONT face="courier new,courier"&gt;_seed=508333952&lt;/FONT&gt;) &lt;EM&gt;before&lt;/EM&gt; the &lt;FONT face="courier new,courier"&gt;do obs=1&lt;/FONT&gt; ... loop. If it is set &lt;EM&gt;within&lt;/EM&gt; that loop, the CALL RANTBL routine (unlike the RANTBL &lt;EM&gt;function&lt;/EM&gt;&amp;nbsp;or the RAND('TABLE',...) function) will use the same seed in all iterations. As a consequence, the selections will not be independent, which has a massive impact on the probability distributions (which I saw in two simulations of 5000 samples each, for the two placements of the &lt;FONT face="courier new,courier"&gt;_seed=&lt;/FONT&gt; assignment statement, with varying seeds of course).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Interestingly, the algorithm (after the correction) does not lead to equal selection probabilities for each employee: If my calculation is correct, the ten probabilities are&lt;/P&gt;
&lt;PRE&gt;19/72&amp;nbsp; &amp;nbsp;≈0.2639 for each emp_no in (1 2 7 3 5 9)
821/2520≈0.3258 for each emp_no in (4 10)
241/630 ≈0.3825 for each emp_no in (6 8)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the PPS sampling method mentioned in my previous post seems to be using yet a different algorithm internally.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2024 20:56:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917834#M361544</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-02-25T20:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917848#M361551</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you. This is a nice algorithm. I assume that you intended to set the second random seed (&lt;FONT face="courier new,courier"&gt;_seed=508333952&lt;/FONT&gt;) &lt;EM&gt;before&lt;/EM&gt; the &lt;FONT face="courier new,courier"&gt;do obs=1&lt;/FONT&gt; ... loop. If it is set &lt;EM&gt;within&lt;/EM&gt; that loop, the CALL RANTBL routine (unlike the RANTBL &lt;EM&gt;function&lt;/EM&gt;&amp;nbsp;or the RAND('TABLE',...) function) will use the same seed in all iterations. As a consequence, the selections will not be independent, which has a massive impact on the probability distributions (which I saw in two simulations of 5000 samples each, for the two placements of the &lt;FONT face="courier new,courier"&gt;_seed=&lt;/FONT&gt; assignment statement, with varying seeds of course).&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;thanks for the note.&amp;nbsp; Yes, I did intend to allow the _seed to be updated over DO loop iterations.&amp;nbsp; I'll correct it in my original response.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2024 23:38:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917848#M361551</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-02-25T23:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917858#M361555</link>
      <description>Is it essential to do proc sort?</description>
      <pubDate>Mon, 26 Feb 2024 02:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917858#M361555</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-02-26T02:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Randomly select  3 rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917861#M361557</link>
      <description>Yes. &lt;BR /&gt;Because I used STRATA statement .</description>
      <pubDate>Mon, 26 Feb 2024 04:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Randomly-select-3-rows-with-condition/m-p/917861#M361557</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-02-26T04:39:36Z</dc:date>
    </item>
  </channel>
</rss>

