<?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: random numbers without repetition in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773921#M37830</link>
    <description>&lt;P&gt;Rick,&lt;/P&gt;
&lt;P&gt;Could randomize it before PROC SURVEYSELECT .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro x;
ods noresult;
%do Replicate=1 %to 100;
data have;
do x=1 to 10;
 id=rand('uniform');
 output;
end;
run;
proc sort data=have;by id;run;
proc surveyselect data=have out=temp sampsize=4 ;
run;
data temp;
 set temp;
 Replicate=&amp;amp;Replicate. ;
run;
proc append base=want data=temp force;run;
%end;
%mend;



proc delete data=want;run;
%x
proc transpose data=want out=final_want;
by Replicate;
var x;
run;



ods result;
proc means data=final_Want;
var col:;
run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Oct 2021 13:23:21 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-10-13T13:23:21Z</dc:date>
    <item>
      <title>random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773793#M37817</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to generate say 100 data points each having 4 variables, and each variable is a random number between 1 and 10 such that each of the 4 variables is unique for a given data point, i.e, no repetition on the data points level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 23:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773793#M37817</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2021-10-12T23:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773797#M37818</link>
      <description>Create a data set with 10 numbers&lt;BR /&gt;Use PROC SURVEYSELECT to randomly select 4, with 100 repetitions and no replacement option per sample. &lt;BR /&gt;If required, transpose the output to your desired format. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2021 23:16:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773797#M37818</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-12T23:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773840#M37822</link>
      <description>&lt;P&gt;Here is a data step approach&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(keep = v:);
   array s {10} _temporary_;
   array v {4};
   
   do i = 1 to 100;
      h = dim(s);
      
      do _N_ = 1 to dim(s);
         s[_N_] = _N_;
      end;
   
      do j = 1 to dim(v);
         r = rand ("integer", h);
         v [j] = s[r];
         
         s [r] = s[h];
         h = h - 1;
      end;
      
      output;
   end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Obs	v1	v2	v3	v4
1	10	4	6	8
2	4	5	10	3
3	1	7	6	8
4	6	9	4	10
5	1	10	9	4

...&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Oct 2021 06:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773840#M37822</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-10-13T06:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773853#M37823</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12982"&gt;@ilikesas&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is an opportunity to employ the rarely used &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n09m1nj1njcyotn138ar9faajbmd.htm" target="_blank" rel="noopener"&gt;CALL RANPERK routine&lt;/A&gt;.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop=_:);
array r[10] v1-v4 _x1-_x6 (1:10);
_seed=27182818;
do _i=1 to 100;
  call ranperk(_seed, 4, of r[*]);
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Oct 2021 07:41:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773853#M37823</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-10-13T07:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773856#M37824</link>
      <description>&lt;P&gt;Another data step approach:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
array vars {4} a b c d;
length all $4 y $1;
do i = 1 to 100;
  all = "";
  do j = 1 to 4;
    do until (not(indexc(all,y)));
      vars{j} = rand('integer',1,10);
      y = put(vars{j} - 1,z1.);
    end;
    substr(all,j,1) = y;
  end;
  output;
end;
keep a b c d;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Oct 2021 08:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773856#M37824</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-13T08:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773892#M37825</link>
      <description>&lt;P&gt;The simplest syntax is to use &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_013/imlug/imlug_langref_sect439.htm" target="_self"&gt;the SAMPLE function&lt;/A&gt; in SAS/IML:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
/* sample 4 items (without replacement) from the items 1:10. Do it 100 times */
X = sample(1:10, {4 100}, "NoReplace");
/* optional: write to SAS data set */
create Want from X[c=('X1':'X4')]; append from X; close;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Oct 2021 11:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773892#M37825</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-10-13T11:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773910#M37826</link>
      <description>&lt;P&gt;As Reeza said.&lt;/P&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;data have;
do x=1 to 10;
 output;
end;
run;

proc surveyselect data=have out=temp sampsize=4 rep=100  &lt;SPAN&gt;OUTRANDOM&amp;nbsp; &lt;/SPAN&gt;;
run;
proc transpose data=temp out=want;
by Replicate;
var x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Oct 2021 11:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773910#M37826</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-14T11:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773916#M37827</link>
      <description>&lt;P&gt;It's worth mentioning that the result of SURVEYSELECT as implemented by Reeza/KSharp will return rows in sorted order. If it is important that the rows themselves be in a random order, then use RANPERK (DATA step) or SAMPLE (SAS/IML).&amp;nbsp; You can check whether the rows are random by computing the mean of each row:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=Want;
var col:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When the rows are in random order, each column has an expected value of 5.5. If the rows are sorted, then the mean of Col1 is less than the mean of Col2, and so forth.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 13:00:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773916#M37827</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-10-13T13:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773917#M37828</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It's worth mentioning that the result of SURVEYSELECT as implemented by Reeza/KSharp will return rows in sorted order. If it is important that the rows themselves be in a random order, then use RANPERK (DATA step) or SAMPLE (SAS/IML).&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;... or add the OUTRANDOM option to the PROC SURVEYSELECT statement.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 13:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773917#M37828</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-10-13T13:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773919#M37829</link>
      <description>&lt;P&gt;PROC PLAN of course!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods exclude all;
proc plan seed=234513;
	factors rep=100 ordered rs=4 of 10 random;
	ods output plan=plan;
	run;
	quit;
ods exclude none;
proc print data=plan;
	run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Oct 2021 13:15:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773919#M37829</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2021-10-13T13:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773921#M37830</link>
      <description>&lt;P&gt;Rick,&lt;/P&gt;
&lt;P&gt;Could randomize it before PROC SURVEYSELECT .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro x;
ods noresult;
%do Replicate=1 %to 100;
data have;
do x=1 to 10;
 id=rand('uniform');
 output;
end;
run;
proc sort data=have;by id;run;
proc surveyselect data=have out=temp sampsize=4 ;
run;
data temp;
 set temp;
 Replicate=&amp;amp;Replicate. ;
run;
proc append base=want data=temp force;run;
%end;
%mend;



proc delete data=want;run;
%x
proc transpose data=want out=final_want;
by Replicate;
var x;
run;



ods result;
proc means data=final_Want;
var col:;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Oct 2021 13:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773921#M37830</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-13T13:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773923#M37831</link>
      <description>&lt;P&gt;Rick,&lt;/P&gt;
&lt;P&gt;You are right . My code is not suited for this question about experiment design .&lt;/P&gt;
&lt;P&gt;I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp; point the right direction by using PROC PLAN .&lt;/P&gt;
&lt;P&gt;of course, you iml code is also right . but maybe OP don't have SAS/IML .&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 13:34:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773923#M37831</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-13T13:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773924#M37832</link>
      <description>Rick,&lt;BR /&gt;I think this one is better .&lt;BR /&gt;&lt;BR /&gt;X = sample(1:10, {4 100}, "WOR");</description>
      <pubDate>Wed, 13 Oct 2021 13:37:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/773924#M37832</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-13T13:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: random numbers without repetition</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/774189#M37870</link>
      <description>Hi, &lt;BR /&gt;It is perfect solution. But need sas version &amp;gt; 9.4M4</description>
      <pubDate>Thu, 14 Oct 2021 11:48:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/random-numbers-without-repetition/m-p/774189#M37870</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-14T11:48:12Z</dc:date>
    </item>
  </channel>
</rss>

