<?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: How to make a primary key for multiple instances of an object? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-primary-key-for-multiple-instances-of-an-object/m-p/729857#M227201</link>
    <description>&lt;P&gt;Create a lookup table and make a format that can be applied to all tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example is here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/fd94b0b6e78815430c1340e8c19f8644" target="_blank"&gt;https://gist.github.com/statgeek/fd94b0b6e78815430c1340e8c19f8644&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Mar 2021 19:01:03 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-03-29T19:01:03Z</dc:date>
    <item>
      <title>How to make a primary key for multiple instances of an object?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-primary-key-for-multiple-instances-of-an-object/m-p/729852#M227198</link>
      <description>&lt;P&gt;Lets say I have a data set consisting of names and I would like to assign them a unique id.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;P&gt;Mary&lt;/P&gt;&lt;P&gt;Jill&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I make sure tom gets the same id even though he shows up twice in the data set?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Mar 2021 18:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-primary-key-for-multiple-instances-of-an-object/m-p/729852#M227198</guid>
      <dc:creator>helloagainoh2</dc:creator>
      <dc:date>2021-03-29T18:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a primary key for multiple instances of an object?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-primary-key-for-multiple-instances-of-an-object/m-p/729853#M227199</link>
      <description>&lt;P&gt;You could do this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $;
datalines;
Tom  
Mary 
Jill 
Tom  
;

data want;
   if _N_ = 1 then do;
      dcl hash h();
      h.definekey('name');
      h.definedata('id');
      h.definedone();
   end;

   set have;

   if h.find() ne 0 then do;
      id + 1; 
      h.add();
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Obs name id 
1   Tom  1 
2   Mary 2 
3   Jill 3 
4   Tom  1 &lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Mar 2021 18:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-primary-key-for-multiple-instances-of-an-object/m-p/729853#M227199</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-03-29T18:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a primary key for multiple instances of an object?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-primary-key-for-multiple-instances-of-an-object/m-p/729854#M227200</link>
      <description>&lt;P&gt;Also, if you don't care that the ID's are increasing, starting from one, you could do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $;
datalines;
Tom  
Mary 
Jill 
Tom  
;

data want;
   set have;
   id = input(md5(name), pib3.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Mar 2021 18:45:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-primary-key-for-multiple-instances-of-an-object/m-p/729854#M227200</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-03-29T18:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a primary key for multiple instances of an object?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-primary-key-for-multiple-instances-of-an-object/m-p/729857#M227201</link>
      <description>&lt;P&gt;Create a lookup table and make a format that can be applied to all tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example is here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/fd94b0b6e78815430c1340e8c19f8644" target="_blank"&gt;https://gist.github.com/statgeek/fd94b0b6e78815430c1340e8c19f8644&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Mar 2021 19:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-make-a-primary-key-for-multiple-instances-of-an-object/m-p/729857#M227201</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-29T19:01:03Z</dc:date>
    </item>
  </channel>
</rss>

