<?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 How to randomise the data in a field? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-randomise-the-data-in-a-field/m-p/21467#M4535</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I have a data set containing names, addresses, phone numbers etc and I need to randomise some of the data so I can share it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ideally I want to change all the first names. Is there anyway I can have a list of say 5 names I choose and then randomly apply them to all the names in my data set e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data Set Name Original:&lt;/P&gt;&lt;P&gt;1. David&lt;/P&gt;&lt;P&gt;2. John&lt;/P&gt;&lt;P&gt;3. Robbie&lt;/P&gt;&lt;P&gt;4. Josh&lt;/P&gt;&lt;P&gt;5. Alex&lt;/P&gt;&lt;P&gt;6. Toby&lt;/P&gt;&lt;P&gt;7. Alan&lt;/P&gt;&lt;P&gt;8. Nigel&lt;/P&gt;&lt;P&gt;10. Ben&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5 names used to randomise:&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;Simon&lt;/P&gt;&lt;P&gt;Ryan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data Set Name after randomisation:&lt;/P&gt;&lt;P&gt;1. Peter&lt;/P&gt;&lt;P&gt;2. Simon&lt;/P&gt;&lt;P&gt;3. Peter&lt;/P&gt;&lt;P&gt;4. Ryan&lt;/P&gt;&lt;P&gt;5. Ryan &lt;/P&gt;&lt;P&gt;6. Mark&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 04 Mar 2012 00:16:23 GMT</pubDate>
    <dc:creator>robwork</dc:creator>
    <dc:date>2012-03-04T00:16:23Z</dc:date>
    <item>
      <title>How to randomise the data in a field?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-randomise-the-data-in-a-field/m-p/21467#M4535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I have a data set containing names, addresses, phone numbers etc and I need to randomise some of the data so I can share it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ideally I want to change all the first names. Is there anyway I can have a list of say 5 names I choose and then randomly apply them to all the names in my data set e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data Set Name Original:&lt;/P&gt;&lt;P&gt;1. David&lt;/P&gt;&lt;P&gt;2. John&lt;/P&gt;&lt;P&gt;3. Robbie&lt;/P&gt;&lt;P&gt;4. Josh&lt;/P&gt;&lt;P&gt;5. Alex&lt;/P&gt;&lt;P&gt;6. Toby&lt;/P&gt;&lt;P&gt;7. Alan&lt;/P&gt;&lt;P&gt;8. Nigel&lt;/P&gt;&lt;P&gt;10. Ben&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5 names used to randomise:&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;Simon&lt;/P&gt;&lt;P&gt;Ryan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data Set Name after randomisation:&lt;/P&gt;&lt;P&gt;1. Peter&lt;/P&gt;&lt;P&gt;2. Simon&lt;/P&gt;&lt;P&gt;3. Peter&lt;/P&gt;&lt;P&gt;4. Ryan&lt;/P&gt;&lt;P&gt;5. Ryan &lt;/P&gt;&lt;P&gt;6. Mark&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Mar 2012 00:16:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-randomise-the-data-in-a-field/m-p/21467#M4535</guid>
      <dc:creator>robwork</dc:creator>
      <dc:date>2012-03-04T00:16:23Z</dc:date>
    </item>
    <item>
      <title>How to randomise the data in a field?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-randomise-the-data-in-a-field/m-p/21468#M4536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt; set have;&lt;/P&gt;&lt;P&gt; name = scan("Peter Paul Mark Simon Ryan",ceil(5*ranuni(0)));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Mar 2012 00:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-randomise-the-data-in-a-field/m-p/21468#M4536</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-03-04T00:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to randomise the data in a field?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-randomise-the-data-in-a-field/m-p/21469#M4537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or if there are too many replacement names to pack it into a string:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp; input name $;&lt;BR /&gt;datalines;&lt;BR /&gt;David&lt;BR /&gt;John&lt;BR /&gt;Robbie&lt;BR /&gt;Josh&lt;BR /&gt;Alex&lt;BR /&gt;Toby&lt;BR /&gt;Alan&lt;BR /&gt;Nigel&lt;BR /&gt;Ben&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data RepNames;&lt;BR /&gt;&amp;nbsp; input RepName $;&lt;BR /&gt;&amp;nbsp; repID=_n_;&lt;BR /&gt;datalines;&lt;BR /&gt;Peter&lt;BR /&gt;Paul&lt;BR /&gt;Mark&lt;BR /&gt;Simon&lt;BR /&gt;Ryan&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(drop=_: repID);&lt;BR /&gt;&amp;nbsp; set have RepNames(obs=0 keep=repID RepName);&lt;BR /&gt;&amp;nbsp; if _n_=1 then&lt;BR /&gt;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare hash h1(dataset:'RepNames');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=h1.defineKey('repID');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=h1.defineData('RepName');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=h1.defineDone();&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; repID=ceil(ranuni(0)*5);&lt;BR /&gt;&amp;nbsp; _rc=h1.find();&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=want;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Mar 2012 00:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-randomise-the-data-in-a-field/m-p/21469#M4537</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-03-04T00:35:39Z</dc:date>
    </item>
    <item>
      <title>How to randomise the data in a field?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-randomise-the-data-in-a-field/m-p/21470#M4538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Building on Tom's suggestion, if the set of random names is in a dataset called &lt;STRONG&gt;otherNames&lt;/STRONG&gt; then you could use :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select name into :randNames SEPARATED BY ' ' from otherNames;&lt;BR /&gt;select count(name) into :nameCount from otherNames;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;BR /&gt;set have;&lt;BR /&gt;name = scan("&amp;amp;randNames.",ceil(&amp;amp;nameCount.*ranuni(0)));&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Mar 2012 01:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-randomise-the-data-in-a-field/m-p/21470#M4538</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-03-04T01:26:53Z</dc:date>
    </item>
  </channel>
</rss>

