<?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 variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509667#M137039</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240554"&gt;@juanvenegas&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;I modified the code because the original code gave me an output data set with 2 million obs and all my variables, but my first_name column had the same value repeating. It turned out to be the first value in the firstnames input dataset.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is it possible that you were misled by looking at only the first few observations before sorting by random number r? In this case, indeed, you'd have seen the &lt;EM&gt;first&lt;/EM&gt; first name multiple times (in fact 1000 times with the &lt;FONT face="courier new,courier"&gt;do _n_=1 to 1000&lt;/FONT&gt; loop) -- but this is correct because the 1001th through 2000th obs. would contain the &lt;EM&gt;second&lt;/EM&gt; first name and so on until the 1,999,001th through 2,000,000th obs. with the &lt;EM&gt;2000th&lt;/EM&gt; first name (hence all first names used, as intended: 2000 first names, each with 1000 observations). The random sort order would be achieved by the final PROC SORT step (&lt;FONT face="courier new,courier"&gt;BY r&lt;/FONT&gt;).&lt;/P&gt;</description>
    <pubDate>Thu, 01 Nov 2018 19:59:17 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2018-11-01T19:59:17Z</dc:date>
    <item>
      <title>Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508874#M136708</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with 2000+ random first names, another dataset with 1000+ first names, and a third dataset with 100+ cities. I wanted to find a way of creating a random combinations of the three variables so that my end result would be a dataset with 2000+ first name, last name, and cities. I have a feeling I would need a do loop of some sort but im stuck. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 18:45:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508874#M136708</guid>
      <dc:creator>juanvenegas</dc:creator>
      <dc:date>2018-10-30T18:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508883#M136711</link>
      <description>&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's suppose your data set names are firstname, lastname and city, and there is also a variable in that data set by the same name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
     create table combined as select *,uniform(0) as rand
     from firstname,lastname,city order by rand;
quit;
data final;
    set combined(obs=2000);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 18:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508883#M136711</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-10-30T18:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508902#M136719</link>
      <description>&lt;P&gt;Hi, unfortunately sas wont stop running when i executed the code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 19:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508902#M136719</guid>
      <dc:creator>juanvenegas</dc:creator>
      <dc:date>2018-10-30T19:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508942#M136743</link>
      <description>&lt;P&gt;The Cartesian product will be HUGE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 21:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508942#M136743</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-10-30T21:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508944#M136745</link>
      <description>&lt;P&gt;Maybe this will work.&amp;nbsp; In the factors statement use the actual obs numbers of your 3 data sets.&amp;nbsp; Noprint is important on factors statement.&amp;nbsp;&amp;nbsp;If you want to keep the obs numbers from the OBS data set created by PROC PLAN assign them to new variables in DATA SAMPLE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data firstname; do firstname=1 to 2000; output; end; run;
data lastname;  do lastname=1 to 1000;  output; end; run;
data city;      do city=1 to 100;       output; end; run;

proc plan;
   factors f=2000 random l=1 of 1000 random c=1 of 100 random / noprint;
   output out=obs;
   run;
proc print data=obs(obs=100); run;
data sample;
   set obs;
   set firstname point=f;
   set lastname point=l;
   set city point=c;
   run;

proc print data=sample(obs=100); run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 21:43:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508944#M136745</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-10-30T21:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508946#M136746</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240554"&gt;@juanvenegas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset with 2000+ random first names, another dataset with 1000+ first names, and a third dataset with 100+ cities. I wanted to find a way of creating a random combinations of the three variables so that my end result would be a dataset with 2000+ first name, last name, and cities. I have a feeling I would need a do loop of some sort but im stuck. Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240554"&gt;@juanvenegas&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to assign random last names and cities to each of the 2000+ first names,&amp;nbsp;try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
call streaminit(27182818);
set firstname;
p1=rand('integer',n1);
set lastname nobs=n1 point=p1;
p2=rand('integer',n2);
set city nobs=n2 point=p2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(I see,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;had a similar idea.)&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 21:52:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508946#M136746</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-30T21:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508947#M136747</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;yours is much better I did not know about RAND("INTEGER").&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 21:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508947#M136747</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-10-30T21:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508951#M136748</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;yours is much better I did not know about RAND("INTEGER").&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thanks. The "integer distribution" is fairly new: see &lt;A href="https://communities.sas.com/t5/SAS-Programming/Assigning-random-numbers-in-a-particular-range-1-18/m-p/508095#M136411" target="_blank"&gt;this post&lt;/A&gt;. I was happy to get it with my recent update to release 9.4M5.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 22:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508951#M136748</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-30T22:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508953#M136749</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;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;yours is much better I did not know about RAND("INTEGER").&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thanks. The "integer distribution" is fairly new: see &lt;A href="https://communities.sas.com/t5/SAS-Programming/Assigning-random-numbers-in-a-particular-range-1-18/m-p/508095#M136411" target="_blank"&gt;this post&lt;/A&gt;. I was happy to get it with my recent update to release 9.4M5.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sh.t I'm way behind this times.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Current version: 9.04.01&lt;U&gt;M3&lt;/U&gt;P062415&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 22:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508953#M136749</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-10-30T22:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508972#M136757</link>
      <description>&lt;P&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;2000&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; * &lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;1000&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; * &lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;100&lt;/FONT&gt; = 200,000,000&amp;nbsp; records.&lt;/P&gt;
&lt;P&gt;Each additional city adds 2,000,000 records depending on how much larger your 2000+ and 1000+ actually are …&lt;/P&gt;
&lt;P&gt;It will take a bit of time.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 23:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/508972#M136757</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-30T23:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509078#M136803</link>
      <description>&lt;P&gt;@FreelanceReinhard Thanks! This worked! If its not too much trouble, could you go over the logic of the code. Also, if I wanted to randomly sort the first col (the first names) since right now they're in alphabetical order, how may I go about doing so. Thanks again!&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 12:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509078#M136803</guid>
      <dc:creator>juanvenegas</dc:creator>
      <dc:date>2018-10-31T12:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509093#M136808</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240554"&gt;@juanvenegas&lt;/a&gt;: You're welcome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an easy way to sort the output dataset randomly:&lt;/P&gt;
&lt;PRE&gt;data want;
call streaminit(27182818);
set firstname;
p1=rand('integer',n1);
set lastname nobs=n1 point=p1;
p2=rand('integer',n2);
set city nobs=n2 point=p2;
&lt;STRONG&gt;&lt;FONT color="#008000"&gt;r=ranuni(31416);&lt;/FONT&gt;&lt;/STRONG&gt;
run;

&lt;FONT color="#008000"&gt;&lt;STRONG&gt;proc sort data=want out=want(drop=r);
by r;
run;
&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;(I used the old RANUNI function because the newer RAND function&amp;nbsp;would share the underlying random number stream with the two other calls of RAND and thus create different assignments of LASTNAME and CITY for all but the first FIRSTNAME. This would not be wrong, but you couldn't just compare the old, alphabetically sorted and the new dataset WANT.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In each iteration of the DATA step the first SET statement reads a first name from dataset FIRSTNAME. At compile time already, the NOBS= options of the second and third SET statement have retrieved the number of observations in datasets LASTNAME and CITY, respectively. This is why variables N1 and N2 can be used successfully in the assignment statements populating variables P1 and P2, although these precede the corresponding SET statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The RAND function using the "integer" distribution and a second argument &lt;EM&gt;k&lt;/EM&gt; (=N1 or N2, resp.) generates a random integer from the set {1, 2, ..., &lt;EM&gt;k&lt;/EM&gt;} (uniform distribution), based on a random number stream that was initialized at the beginning of the&amp;nbsp;DATA step by means of the CALL STREAMINIT routine (27182818 is an arbitrary seed value). Thus, P1 and P2 are assigned randomly selected &lt;EM&gt;observation numbers&lt;/EM&gt; from dataset LASTNAME and CITY, respectively.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second and third SET statement use the POINT= option to designate the next observation to read, i.e., they read the observations specified by P1 and P2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the extended DATA step above, variable R is assigned a random number from&amp;nbsp;the continuous uniform distribution on the interval [0, 1]. Only this variable&amp;nbsp;and the variables contained in datasets FIRSTNAME, LASTNAME and CITY are written to dataset WANT because variables in the NOBS= and POINT= options of the SET statement are automatically dropped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DATA step terminates after all observations from dataset FIRSTNAME have been processed as described above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The PROC SORT step sorts dataset WANT by R, hence randomly, and sheds variable R (using a DROP= dataset option), which is no longer needed.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 13:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509093#M136808</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-31T13:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509099#M136812</link>
      <description>&lt;P&gt;Thanks for everything!&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 13:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509099#M136812</guid>
      <dc:creator>juanvenegas</dc:creator>
      <dc:date>2018-10-31T13:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509103#M136815</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;I expecting you to do this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   call streaminit(27182818);
   do _n_ = 1 to n0;
      p0=rand('integer',n0)
      set firstname nobs=n0 point=p0;
      p1=rand('integer',n1);
      set lastname nobs=n1 point=p1;
      p2=rand('integer',n2);
      set city nobs=n2 point=p2;
      output;
      end;
   STOP;
   run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Oct 2018 13:40:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509103#M136815</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-10-31T13:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509107#M136817</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;,&amp;nbsp;this was in fact the first impulse I had, too (even with the same variable names N0, P0). However, I stopped going this way when I realized that this would not use all first names in dataset FIRSTNAME, but only about 63%. (Okay, datasets LASTNAME and CITY aren't&amp;nbsp;always fully exhausted either, but the expected rates are higher.)&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 13:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509107#M136817</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-31T13:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509113#M136820</link>
      <description>&lt;P&gt;John King,&lt;/P&gt;
&lt;P&gt;Why not PROC SURVEYSELECT which is more efficient I think.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc surveyselect data=firstname out=a method=srs sampsize=200 reps=10 ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc surveyselect data=lastname out=b method=srs sampsize=200 reps=10 ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc surveyselect data=city out=c method=urs sampsize=200 reps=10 ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;merge a b c;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 12:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509113#M136820</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-11-02T12:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509127#M136828</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;for presenting another elegant&amp;nbsp;solution. Of course, with METHOD=URS again not all first names would be used (in general). Also, the DATA step solution doesn't&amp;nbsp;need hardcoded sample sizes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding&amp;nbsp;efficiency:&lt;/P&gt;
&lt;PRE&gt;216  data want;
217  call streaminit(27182818);
218  set firstname;
219  p1=rand('integer',n1);
220  set lastname nobs=n1 point=p1;
221  p2=rand('integer',n2);
222  set city nobs=n2 point=p2;
223  run;

NOTE: There were 2000 observations read from the data set WORK.FIRSTNAME.
NOTE: The data set WORK.WANT has 2000 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Oct 2018 14:31:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509127#M136828</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-31T14:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509180#M136843</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;I had thought a bit about the full sample issue as you mention &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240554"&gt;@juanvenegas&lt;/a&gt;&amp;nbsp;did not give much detail about that.&amp;nbsp; If we generate&amp;nbsp;permutations for last name and city in blocks we can insure full use of all first last and city names.&amp;nbsp; Back to PROC PLAN one of my favorite procedures. &lt;img id="robothappy" class="emoticon emoticon-robothappy" src="https://communities.sas.com/i/smilies/16x16_robot-happy.png" alt="Robot Happy" title="Robot Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data firstname; do fn=1 to 341; firstname='F: '||put(fn,words64.); output; end; run; %let f0=&amp;amp;SYSNOBS;
data lastname;  do ln=1 to 134; lastname ='L: '||put(ln,words64.); output; end; run; %let l0=&amp;amp;SYSNOBS;
data city;      do cn=1 to 15;  city     ='C: '||put(cn,words64.); output; end; run; %let c0=&amp;amp;SYSNOBS;

proc plan seed=1234;
   factors f=&amp;amp;f0 random                                    / noprint;   output out=fobs;   run;
   factors r1=%sysevalf(&amp;amp;f0/&amp;amp;l0,ceil) ordered l=&amp;amp;l0 random / noprint;   output out=lobs;   run;
   factors r2=%sysevalf(&amp;amp;f0/&amp;amp;c0,ceil) ordered c=&amp;amp;c0 random / noprint;   output out=cobs;   run;
   quit;

data sample;
   merge fobs(in=in1) lobs cobs;
   if not in1 then stop;
   p1=f; p2=l; p3=c;
   set firstname point=p1;
   set lastname point=p2;
   set city point=p3;
   run;

proc print data=sample(obs=100); run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24533i1DB07F6CE909A5EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 15:48:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509180#M136843</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-10-31T15:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509190#M136849</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;, looks interesting. I'll take a closer look later.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240554"&gt;@juanvenegas&lt;/a&gt;: As you can see, your question was really inspiring. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 16:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509190#M136849</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-31T16:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: Random combination of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509202#M136856</link>
      <description>&lt;P&gt;These are all great. Last question. I now have a dataset with 2000+ observations with variables such as first_name, last_name, city, etc. If I wanted to create a dataset with over 2,000,000 observations using the dataset I already have, how would I go about that? Would it be&amp;nbsp;efficient to just to stack datasets on top of one another until i reach 2,000,000 and then randomly sort? Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 16:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-combination-of-variables/m-p/509202#M136856</guid>
      <dc:creator>juanvenegas</dc:creator>
      <dc:date>2018-10-31T16:36:23Z</dc:date>
    </item>
  </channel>
</rss>

