<?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 combination of a subset of data set in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266657#M2699</link>
    <description>&lt;P&gt;You guys are just incredible!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks. Let me digest this.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Apr 2016 09:10:02 GMT</pubDate>
    <dc:creator>SWEETSAS</dc:creator>
    <dc:date>2016-04-27T09:10:02Z</dc:date>
    <item>
      <title>Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266609#M2694</link>
      <description>&lt;P&gt;Input id $ x y;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Datalines;&lt;/P&gt;
&lt;P&gt;00-01 5 3&lt;/P&gt;
&lt;P&gt;00-02 4 6&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;00-03&amp;nbsp;&lt;/SPAN&gt;6 4&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;00-04&amp;nbsp;&lt;/SPAN&gt;7 5&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;00-05&amp;nbsp;&lt;/SPAN&gt;9 2&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;00-06&amp;nbsp;&lt;/SPAN&gt;4 6&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;00-07&amp;nbsp;&lt;/SPAN&gt;5 8&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;00-08&amp;nbsp;&lt;/SPAN&gt;1 8&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;00-09&amp;nbsp;&lt;/SPAN&gt;7 3&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;00-10 &amp;nbsp;&lt;/SPAN&gt;7 4&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;Please, I want to generate Z random subset of data set CO chosen observation 4 at a time (10 chose 4). Let’s take Z in this case=7; I like to add additional column to identify each of the random subset—let call that variable REPS. I will appreciate a code that can run fast because the actual code might end up having up to 10,000 REPS. And number of variables can be larger.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I read Rick's blog and saw some examples, but I did not see an example where the combination involve actual data set. If it's not possible for more than a variable, I can do only the id (character variable) and merge back to the original data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help will be appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in Advance&lt;/P&gt;
&lt;P&gt;Jack&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 02:45:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266609#M2694</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2016-04-27T02:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266612#M2695</link>
      <description>&lt;P&gt;Proc surveyselect will work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 03:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266612#M2695</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-27T03:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266613#M2696</link>
      <description>&lt;P&gt;Selection with or without replacement?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 03:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266613#M2696</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-27T03:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266616#M2697</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;suggested:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data CO;
Input id $ x y;
Datalines;
00-01 5 3
00-02 4 6
00-03 6 4
00-04 7 5
00-05 9 2
00-06 4 6
00-07 5 8
00-08 1 8
00-09 7 3
00-10  7 4
;

proc surveyselect data=CO 
    method=srs /* Simple Random sampling without replacement */
    /*method=urs outhits*/ /* Simple Random sampling with replacement */
    reps=10 sampsize=4 
    out=COsamples seed=896358; 
run;

proc print data=COsamples noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2016 04:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266616#M2697</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-04-27T04:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266625#M2698</link>
      <description>&lt;P&gt;Does PG's code make some sense ?&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; it IS possible for more than a variable for IML, But need some more code , and might not be friendly . You really want IML code ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
Input id $ x y;
Datalines;
00-01 5 3
00-02 4 6
00-03 6 4
00-04 7 5
00-05 9 2
00-06 4 6
00-07 5 8
00-08 1 8
00-09 7 3
00-10  7 4
;
run;
proc iml;
z=7;
k=4;

use have nobs nobs;
read all var{id x y};
close;
r=rancomb(nobs,k,z);



 new_id=j(k,1,blankstr(nleng(id)));
create want var{reps new_id new_x new_y};
do i=1 to nrow(r);
 idx=r[i,];
 reps=j(k,1,i);
 new_id=id[idx];
 new_x=x[idx];
 new_y=y[idx];
 append;
end;
close;

quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 09:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266625#M2698</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-27T09:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266657#M2699</link>
      <description>&lt;P&gt;You guys are just incredible!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks. Let me digest this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 09:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266657#M2699</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2016-04-27T09:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266659#M2700</link>
      <description>&lt;P&gt;Incredible!!!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me evalute to this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 09:12:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266659#M2700</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2016-04-27T09:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266665#M2701</link>
      <description>&lt;P&gt;This is vectorize operation . Could be very fast.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
Input id $ x y;
Datalines;
00-01 5 3
00-02 4 6
00-03 6 4
00-04 7 5
00-05 9 2
00-06 4 6
00-07 5 8
00-08 1 8
00-09 7 3
00-10  7 4
;
run;
proc iml;
z=7;
k=4;

use have nobs nobs;
read all var{id x y};
close;
r=rancomb(nobs,k,z);


 idx=colvec(r);
 reps =colvec(row(r));
 new_id=id[idx];
 new_x=x[idx];
 new_y=y[idx];
create want var{reps new_id new_x new_y};
append;
close;

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2016 09:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266665#M2701</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-27T09:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266698#M2702</link>
      <description>&lt;P&gt;This blog post explains&amp;nbsp;to how to sample with or without replacement: &lt;A href="http://blogs.sas.com/content/iml/2016/02/15/essential-sampling-methods.html" target="_self"&gt;"Four essential sampling methods in SAS"&lt;/A&gt;. &amp;nbsp;It links to other articles that provide details. It shows how to do the sampling by using PROC SURVEYSELECT and by using the SAMPLE function in SAS/IML.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 13:18:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266698#M2702</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-04-27T13:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266763#M2703</link>
      <description>&lt;P&gt;It's basicacally to obtain a random subset of possible permutations of the data set. The reason is that in some settings, computer memory might limit the enumeration of all permutations. Therefor, a sufficiently large number of permutaion of the data set should suffice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;J&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 16:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266763#M2703</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2016-04-27T16:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266764#M2704</link>
      <description>&lt;P&gt;Thanks Rick!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 16:43:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266764#M2704</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2016-04-27T16:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266876#M2706</link>
      <description>&lt;P&gt;All the answers are essentially correct. Thank you all very very much.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 23:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266876#M2706</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2016-04-27T23:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of a subset of data set</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266887#M2708</link>
      <description>This is correct answer as well</description>
      <pubDate>Thu, 28 Apr 2016 01:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Random-combination-of-a-subset-of-data-set/m-p/266887#M2708</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2016-04-28T01:12:23Z</dc:date>
    </item>
  </channel>
</rss>

