<?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: unique random identifiers in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139375#M37302</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Get a distinct list of building IDs.&lt;/P&gt;&lt;P&gt;Generate a set of random IDs that meet your criteria.&lt;/P&gt;&lt;P&gt;Create a format out of that&lt;/P&gt;&lt;P&gt;Apply the format in dataset to get your new ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table distinct_id as&lt;/P&gt;&lt;P&gt;select distinct buildingID, put( round(100000*Ranuni(327),1),z5.) as randomID from have as A;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*create your format;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*apply format;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;randomID=input(buildingID, $randomID_fmt);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Apr 2014 16:18:24 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2014-04-30T16:18:24Z</dc:date>
    <item>
      <title>unique random identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139370#M37297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial; font-size: small; background-color: #ffffff;"&gt;Hello -&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial; font-size: small;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial; font-size: small;"&gt;I have a data set that includes a number of buildings, with multiple records for each building.&amp;nbsp; I want to generate random 5-digit ID for each building, and I want the same ID to apply to each observation from a given building. &lt;/P&gt;&lt;P style="color: #222222; font-family: arial; font-size: small;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial; font-size: small;"&gt;I was able to generate IDs for the buildings, like so:&lt;/P&gt;&lt;P style="color: #222222; font-family: arial; font-size: small;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial; font-size: small;"&gt;&lt;/P&gt;&lt;DIV&gt;data new; set old;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if building^=lag(building) then BuildingID+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else BuildingID+0;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;/DIV&gt;&lt;P style="color: #222222; font-family: arial; font-size: small;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial; font-size: small;"&gt;However, this gives me IDs that start with 1 and progress consecutively.&amp;nbsp; I really want the IDs to be randomly generated, 5-digit numbers.&amp;nbsp; I can't see how to do this while maintaining the same ID across multiple records for a given building.&amp;nbsp; &lt;/P&gt;&lt;P style="color: #222222; font-family: arial; font-size: small;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial; font-size: small;"&gt;Any assistance is appreciated. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Apr 2014 15:18:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139370#M37297</guid>
      <dc:creator>grayab</dc:creator>
      <dc:date>2014-04-30T15:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: unique random identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139371#M37298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data new; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set old; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bnum = put( round(100000*Ranuni(327),1),z5.); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will get you close, though you need to check to see if any duplicates are created in the BNUM.&lt;/P&gt;&lt;P&gt;Since I don't think an identifier variable should have arithmetic performed on it I don't think there should be a problem with a character variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or if you really want a numeric, take out the put, though some of the results will be fewer than 5 digits.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Apr 2014 15:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139371#M37298</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-04-30T15:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: unique random identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139372#M37299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for this suggestion.&amp;nbsp; I tried it, and it did generate random 5 digit numbers. However, it did not maintain the same buildingID across multiple records from the same building. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here, in essence, is what I got:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;BuildingName&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="text-decoration: underline;"&gt; BuildingID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;FirstBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23456&lt;/P&gt;&lt;P&gt;FirstBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 87567&lt;/P&gt;&lt;P&gt;FirstBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 92345&lt;/P&gt;&lt;P&gt;SecondBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 87454&lt;/P&gt;&lt;P&gt;SecondBLdgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 67845&lt;/P&gt;&lt;P&gt;ThirdBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 46789&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I need:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;BuildingName&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="text-decoration: underline;"&gt; BuildingID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;FirstBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23456&lt;/P&gt;&lt;P&gt;FirstBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23456&lt;/P&gt;&lt;P&gt;FirstBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23456&lt;/P&gt;&lt;P&gt;SecondBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 87454&lt;/P&gt;&lt;P&gt;SecondBLdgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 87454&lt;/P&gt;&lt;P&gt;ThirdBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 46789&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Apr 2014 15:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139372#M37299</guid>
      <dc:creator>grayab</dc:creator>
      <dc:date>2014-04-30T15:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: unique random identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139373#M37300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Get the uniquie buildings and assign the number.&lt;/P&gt;&lt;P&gt;Then merge the data.&lt;/P&gt;&lt;P&gt;Note: New will be in building order when finished. If for some reason you need to keep an existing order you may need an order variable OR the create table can have an Order clause after the From to sort the data: order by var1, var2, var3 as needed.&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table uniquebldg as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct building, put( round(100000*Ranuni(327),1),z5.) as bnum&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from old;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create table new as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select a.*, b.bnum&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from old as a left join uniquebldg as b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on a.building=b.building;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Apr 2014 16:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139373#M37300</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-04-30T16:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: unique random identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139374#M37301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is one way to insure you have random list of five digit numbers from 10000 to 99999.&amp;nbsp; Then to apply that to your data get(set) one from the list when FIRST.BUILDINGNAME.&amp;nbsp; You may need to sort your building data first if the buildings are not grouped.&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;plan&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;seed&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;32329&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;factors&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; randomID=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;90000&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; / &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;noprint&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;output&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=randomID randomID &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;nvals&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=(&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;10000&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; to &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;99999&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;quit&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; buildings;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; buildingName :&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$32.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;FirstBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;FirstBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;FirstBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;SecondBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;SecondBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;SecondBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;SecondBLdgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;SecondBLdgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;SecondBLdgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;SecondBLdgName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;ThirdBldgName&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;;;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; building2;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; buildings;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; buildingname &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;notsorted&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; first.buildingname &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; randomid;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;IMG alt="4-30-2014 11-14-55 AM.png" class="jive-image" src="https://communities.sas.com/legacyfs/online/6189_4-30-2014 11-14-55 AM.png" /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Apr 2014 16:16:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139374#M37301</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-04-30T16:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: unique random identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139375#M37302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Get a distinct list of building IDs.&lt;/P&gt;&lt;P&gt;Generate a set of random IDs that meet your criteria.&lt;/P&gt;&lt;P&gt;Create a format out of that&lt;/P&gt;&lt;P&gt;Apply the format in dataset to get your new ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table distinct_id as&lt;/P&gt;&lt;P&gt;select distinct buildingID, put( round(100000*Ranuni(327),1),z5.) as randomID from have as A;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*create your format;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*apply format;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;randomID=input(buildingID, $randomID_fmt);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Apr 2014 16:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139375#M37302</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-04-30T16:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: unique random identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139376#M37303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data new;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;set old;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;by buildingname;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;retain bnum;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if first.buildingname then bnum = put( round(100000*Ranuni(327),1),z5.);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Or another function:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data x;
length uuid $ 5;
do i=1 to 100;
 uuid=compress(uuidgen(), ,'kd');
 output;
 end;
 run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 May 2014 09:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139376#M37303</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-05-01T09:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: unique random identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139377#M37304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This worked perfectly.&amp;nbsp; THank you. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 May 2014 13:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/139377#M37304</guid>
      <dc:creator>grayab</dc:creator>
      <dc:date>2014-05-01T13:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: unique random identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/313637#M61509</link>
      <description>&lt;P&gt;Is it possible that the same random id can be repeated for more than one building name?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 02:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/313637#M61509</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-11-23T02:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: unique random identifiers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/648177#M78666</link>
      <description>What is the firstbuildingname comes in the 12th observation? I want the same ID even if it comes later in the observation.</description>
      <pubDate>Fri, 15 May 2020 21:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-random-identifiers/m-p/648177#M78666</guid>
      <dc:creator>Smitha9</dc:creator>
      <dc:date>2020-05-15T21:52:30Z</dc:date>
    </item>
  </channel>
</rss>

