<?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: Creating a new unique ID variable from two variables in merged data with repetition of one varia in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-unique-ID-variable-from-two-variables-in-merged/m-p/385170#M277131</link>
    <description>&lt;P&gt;Well you could replace the last two statements with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if first.year then ID + 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, you don't really need an ID variable, &amp;nbsp;You could just use the combination of PHYCODE and YEAR to identify a physician.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Aug 2017 03:20:18 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-08-03T03:20:18Z</dc:date>
    <item>
      <title>Creating a new unique ID variable from two variables in merged data with repetition of one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-unique-ID-variable-from-two-variables-in-merged/m-p/385160#M277130</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would love some help with this, as I think I am doing something wrong here in SAS. &amp;nbsp;I merged multiple years of data, but I wanted to create a unique ID variable ("ID") to identify each unique physician ("phycode"). &amp;nbsp;For each individual year, the "phycode" is unique for every physician. &amp;nbsp;However, the "phycode" is repeated in subsequent years for other physicians so both "phycode" and "year" are necessary to create a new unique ID in the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what my data looks like now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Phycode &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Year&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2004&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;2005&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2004&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2005&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2004&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2004&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want my output to produce a table like this in recognition that repeat phycodes in different years represent unique physicians (ID):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Phycode &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Year &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ID&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2004 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;2005 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2004 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2005 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2004 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2004 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I tried:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc sort data=IN.NAMCS0514;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;by phycode year;&lt;/DIV&gt;&lt;DIV&gt;run;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data=UniqueID;&lt;/DIV&gt;&lt;DIV&gt;set NSS0514;&lt;/DIV&gt;&lt;DIV&gt;by phycode year;&lt;/DIV&gt;&lt;DIV&gt;if &amp;nbsp;first.phycode then ID=1;&lt;/DIV&gt;&lt;DIV&gt;ID +1;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2017 02:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-unique-ID-variable-from-two-variables-in-merged/m-p/385160#M277130</guid>
      <dc:creator>gonzy31</dc:creator>
      <dc:date>2017-08-03T02:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new unique ID variable from two variables in merged data with repetition of one varia</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-unique-ID-variable-from-two-variables-in-merged/m-p/385170#M277131</link>
      <description>&lt;P&gt;Well you could replace the last two statements with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if first.year then ID + 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, you don't really need an ID variable, &amp;nbsp;You could just use the combination of PHYCODE and YEAR to identify a physician.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2017 03:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-unique-ID-variable-from-two-variables-in-merged/m-p/385170#M277131</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-03T03:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new unique ID variable from two variables in merged data with repetition of one varia</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-unique-ID-variable-from-two-variables-in-merged/m-p/385175#M277132</link>
      <description>&lt;P&gt;Your output matches:&lt;/P&gt;
&lt;DIV&gt;data UniqueID;&lt;/DIV&gt;
&lt;DIV&gt;set NSS0514;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;ID +1;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;</description>
      <pubDate>Thu, 03 Aug 2017 03:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-unique-ID-variable-from-two-variables-in-merged/m-p/385175#M277132</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-08-03T03:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new unique ID variable from two variables in merged data with repetition of one varia</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-unique-ID-variable-from-two-variables-in-merged/m-p/385268#M277133</link>
      <description>&lt;P&gt;Thank you both! That worked perfectly.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2017 12:42:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-unique-ID-variable-from-two-variables-in-merged/m-p/385268#M277133</guid>
      <dc:creator>gonzy31</dc:creator>
      <dc:date>2017-08-03T12:42:38Z</dc:date>
    </item>
  </channel>
</rss>

