<?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 selection of rows from various datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393284#M94695</link>
    <description>&lt;P&gt;You can use the POINT= options of the SET statement to randomly read an observation. To calculate the random observation number you can use the RANUNI function together with the CEIL function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The NOBS= option on the SET statement will return the total number of observations in SAS data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DATA step will read the data set with all the logins, you then calculate a random number to read from the password data set&lt;/P&gt;</description>
    <pubDate>Tue, 05 Sep 2017 16:11:02 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2017-09-05T16:11:02Z</dc:date>
    <item>
      <title>Random selection of rows from various datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393269#M94690</link>
      <description>&lt;P&gt;I have a dataset containing 20 User Logins. (Only Var = Login)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 2 other datasets each containing 1 var.&lt;/P&gt;
&lt;P&gt;PWSource1 contains 50 freshly prepared Passwords in a var called PW1.&lt;/P&gt;
&lt;P&gt;PWSource2 contains about 90 other freshly prepared Passwords in a Var called PW2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to select the Login from UserLogins (in=a) and then a &lt;STRONG&gt;random&lt;/STRONG&gt; passw from PWSource1 (from PW1) and a second &lt;STRONG&gt;random&lt;/STRONG&gt; password from PWSource2.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each Login I will combine PW1 and PW2 to make a single Password in my final output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Has anyone got some sample code or suggestions on how to code the random selection of each Password per Login?&lt;/P&gt;
&lt;P&gt;Any help will be much appreciated...&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Len&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 15:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393269#M94690</guid>
      <dc:creator>Lenvdb</dc:creator>
      <dc:date>2017-09-05T15:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Random selection of rows from various datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393284#M94695</link>
      <description>&lt;P&gt;You can use the POINT= options of the SET statement to randomly read an observation. To calculate the random observation number you can use the RANUNI function together with the CEIL function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The NOBS= option on the SET statement will return the total number of observations in SAS data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DATA step will read the data set with all the logins, you then calculate a random number to read from the password data set&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 16:11:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393284#M94695</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-09-05T16:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Random selection of rows from various datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393288#M94697</link>
      <description>&lt;P&gt;To add some detail to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32"&gt;@BrunoMueller&lt;/a&gt;&amp;nbsp;suggestion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set users;&lt;/P&gt;
&lt;P&gt;recno = ceil(n_pw1 * ranuni(12345));&lt;/P&gt;
&lt;P&gt;set pw1 nobs=n_pw1 point=recno;&lt;/P&gt;
&lt;P&gt;recno = ceil(n_pw2 * ranuni(97531));&lt;/P&gt;
&lt;P&gt;set pw1 nobs=n_pw2 point=recno;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 16:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393288#M94697</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-05T16:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: Random selection of rows from various datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393312#M94704</link>
      <description>&lt;P&gt;Can the passwords be reused?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 17:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393312#M94704</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-05T17:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Random selection of rows from various datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393393#M94721</link>
      <description>&lt;P&gt;If you want to make sure that the passwords are not reused then you could use this method:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data rLogins;
set logins;
rnd = rand("UNIFORM");
run;

data rPW1;
set PW1;
rnd = rand("UNIFORM");
run;

data rPW2;
set PW2;
rnd = rand("UNIFORM");
run;

proc sort data=rLogins; by rnd; run;
proc sort data=rPW1; by rnd; run;
proc sort data=rPW2; by rnd; run;

data want;
set rLogins;
set rPW1;
set rPW2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Sep 2017 22:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393393#M94721</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-09-05T22:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Random selection of rows from various datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393450#M94747</link>
      <description>&lt;P&gt;Hi Reeza&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Passwords can be reused, but each combination of PW1 +&amp;nbsp;PW2 should be unique:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A + M&amp;nbsp;= AM &amp;nbsp;&amp;gt;&amp;gt; OK&lt;/P&gt;
&lt;P&gt;A + N&amp;nbsp;= AN &amp;nbsp;&amp;gt;&amp;gt; OK&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;B + M = BM &amp;gt;&amp;gt; OK&lt;/P&gt;
&lt;P&gt;C + N = CN &amp;gt;&amp;gt; OK&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A + M = AM &amp;gt;&amp;gt; Not OK as it is already used&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 08:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393450#M94747</guid>
      <dc:creator>Lenvdb</dc:creator>
      <dc:date>2017-09-06T08:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Random selection of rows from various datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393459#M94752</link>
      <description>Thank you Astounding! this is perfect. much appreciated</description>
      <pubDate>Wed, 06 Sep 2017 08:40:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393459#M94752</guid>
      <dc:creator>Lenvdb</dc:creator>
      <dc:date>2017-09-06T08:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Random selection of rows from various datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393466#M94755</link>
      <description>&lt;P&gt;It takes a slightly different approach to make sure passwords are not reused.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;/P&gt;
&lt;P&gt;create table password_list as select * from pw1, pw2;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;data password_list2;&lt;/P&gt;
&lt;P&gt;set password_list;&lt;/P&gt;
&lt;P&gt;random_order = ranuni(12345);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc sort data=password_list2;&lt;/P&gt;
&lt;P&gt;by random_order;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set users;&lt;/P&gt;
&lt;P&gt;set password_list2 (drop=random_order);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;may be successful. &amp;nbsp;It will limit the number of passwords that can be assigned to 50 (the smaller number from the PW1 and PW2 data sets).&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 09:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-rows-from-various-datasets/m-p/393466#M94755</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-06T09:20:28Z</dc:date>
    </item>
  </channel>
</rss>

