<?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: PROC SURVEYSELECT - sampling without replacement with consecutive randomly permutating in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291534#M15496</link>
    <description>&lt;P&gt;So, what you want is to reorder a sample randomly. Simply sort your sample by a random variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data myClass;
set sashelp.class;
rnd = rand("uniform");
run;

proc sort data=myClass out=myClass(drop=rnd); 
by rnd; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 13 Aug 2016 17:40:24 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-08-13T17:40:24Z</dc:date>
    <item>
      <title>PROC SURVEYSELECT - sampling without replacement with consecutive randomly permutating</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291518#M15495</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would be glad, if you could help me with the following issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My aim is to draw N observations from a N-observation containing data-set, without replacement.&lt;/P&gt;&lt;P&gt;("I want to draw the urn empty, without replacement")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Utilizing proc iml, I am only capable of drawing a &lt;EM&gt;single value&lt;/EM&gt; from a column-vector.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
s = sample(1:20, {20}, "WOR");
print s;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, "proc iml" has this nice "WOR" option -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"specifies simple random sampling without replacement. After elements are randomly selected, their order is randomly permuted. "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is exactly, what I would like to have.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With "PROC SURVEYSELECT", utilizing the "srs" method, I only get the result I would get as with &lt;SPAN class="term"&gt;&lt;SPAN class="quote"&gt;specifying “NoReplace" in the "P&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="term"&gt;&lt;SPAN class="quote"&gt;ROC IML" statement -&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* N denotes the sample size;&lt;BR /&gt;%LET N = 100&lt;BR /&gt;proc surveyselect data = input method=srs
  sampsize = &amp;amp;N. out = output;
  id _all_;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- just a copy of my input-data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In short, I am looking for the "method=" &lt;STRONG&gt;correspondent to "WOR"&lt;/STRONG&gt; in "PROC IML" - that is, that the input data set is "drawn empty".&lt;/P&gt;&lt;P&gt;Likewise, I would like to know, how I can use the "PROC IML"&amp;nbsp; "sample" function, in order to &lt;STRONG&gt;sample vectors&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would be very glad, if you could help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yours sincerely,&lt;/P&gt;&lt;P&gt;Sinisturm&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;</description>
      <pubDate>Sat, 13 Aug 2016 12:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291518#M15495</guid>
      <dc:creator>Sinistrum</dc:creator>
      <dc:date>2016-08-13T12:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYSELECT - sampling without replacement with consecutive randomly permutating</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291534#M15496</link>
      <description>&lt;P&gt;So, what you want is to reorder a sample randomly. Simply sort your sample by a random variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data myClass;
set sashelp.class;
rnd = rand("uniform");
run;

proc sort data=myClass out=myClass(drop=rnd); 
by rnd; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2016 17:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291534#M15496</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-08-13T17:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYSELECT - sampling without replacement with consecutive randomly permutating</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291555#M15499</link>
      <description>&lt;PRE&gt;
For your second question:


proc iml;
use sashelp.class;
read all var _num_ into x[c=vnames];
close;

v=sample(vnames,1,'wor');
want=x[,v];

print want[c=v l=''];
quit;

&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Aug 2016 02:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291555#M15499</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-14T02:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYSELECT - sampling without replacement with consecutive randomly permutating</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291561#M15500</link>
      <description>&lt;P&gt;Thank you very much to both of you -&lt;/P&gt;&lt;P&gt;PG for simplifying and solving my issue (I only want to reorder the sample randomly)&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;Xia Keshan for dealing with my "proc iml" issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Either, I am too clumsy to get your solution to work, or, I do not have expressed my wish well enough.&lt;/P&gt;&lt;P&gt;What I want to do, is "draw from the rows of a NxE-matrix ", such that I get N row-vectors (matrix is "drawn empty") and write this draws to a data set with N rows and E columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just came across &lt;A href="http://blogs.sas.com/content/iml/2014/01/23/sampling-with-replacement-easier.html" target="_self"&gt;this solution&lt;/A&gt;, which, I hope, does implement what I strive for:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
call randseed(1);
use Sashelp.Cars nobs N;
varNames = {"MPG_City" "Length" "Weight"};
read all var varNames into x[rowname=Model];
close Sashelp.Cars;
 
obsIdx = sample(1:nrow(x), N);   /* sample size=N, rows chosen from 1:NumRows */
s5 = x[obsidx, ];                /* extract subset of rows */
print s5[rowname=(Model[obsIdx]) colname=varNames];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(in the original, sample size is "5"; "nobs N" is added 5 changed to N, by me).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, thank you a lot.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Aug 2016 06:31:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291561#M15500</guid>
      <dc:creator>Sinistrum</dc:creator>
      <dc:date>2016-08-14T06:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYSELECT - sampling without replacement with consecutive randomly permutating</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291566#M15501</link>
      <description>&lt;PRE&gt;
So both question are the same ?
You want draw row vector not column vector ?




proc iml;
use sashelp.class nobs n;
read all var _num_ into x;
close;

idx=ranperm(n);
want=x[idx,];

print want[l=''];
quit;


&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Aug 2016 09:43:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291566#M15501</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-14T09:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYSELECT - sampling without replacement with consecutive randomly permutating</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291568#M15502</link>
      <description>&lt;P&gt;Your syntax will be simpler and your meaning clearer if you use the RANPERM function in IML instead of the SAMPLE function.&lt;/P&gt;
&lt;P&gt;Sampling N items without replacement&amp;nbsp;from a set that contains N elements is a permutation of the elements:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
s = ranperm(1:20);  /* equivalent to sample(1:20, 20, "WOR"); */
print s;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Aug 2016 10:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291568#M15502</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-08-14T10:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SURVEYSELECT - sampling without replacement with consecutive randomly permutating</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291578#M15503</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; wrote:&lt;BR /&gt;&lt;PRE&gt;So both question are the same ?
You want draw row vector not column vector ?

&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yes, both questions are the same - that is, what I meant with "likewise". I should have expressed my question better - I am sorry for that.&lt;/P&gt;&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; wrote:&lt;BR /&gt;&lt;P&gt;Your syntax will be simpler and your meaning clearer if you use the RANPERM function in IML instead of the SAMPLE function.&lt;/P&gt;&lt;P&gt;Sampling N items without replacement&amp;nbsp;from a set that contains N elements is a permutation of the elements:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
s = ranperm(1:20);  /* equivalent to sample(1:20, 20, "WOR"); */
print s;&lt;/CODE&gt;&lt;/PRE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, this eventually brings together PG's comment and my desire to solve it via "proc iml".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for&lt;/P&gt;&lt;P&gt;- showing me the right commands in SAS, as well as,&lt;/P&gt;&lt;P&gt;- clarifying, what I am actually aiming for (which I should have known by myself).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once again, I am really happy to see that great kind of a help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Aug 2016 12:10:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/PROC-SURVEYSELECT-sampling-without-replacement-with-consecutive/m-p/291578#M15503</guid>
      <dc:creator>Sinistrum</dc:creator>
      <dc:date>2016-08-14T12:10:33Z</dc:date>
    </item>
  </channel>
</rss>

