<?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 do I create a unique ID based on four patient variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-unique-ID-based-on-four-patient-variables/m-p/268706#M310484</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to using SAS. I have a query about creating a unique ID for a group of patients that is based on a number of variables in SAS 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 276 episodes of care, in which the same patient may have presented multiple times. I have no unique ID for them and I would like to create one. The 276 episodes of care have been pulled out of 14,000 episodes in which there was a unique ID for those episodes but it is missing for the 276 episodes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variables I have to identify the patients are: surname, given initial, birth date and gender.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have done so far and where my problem is (code and screen shots below):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the 276 episodes of care I got rid of the duplicate patients based on the above variables (there are 240 patients in the 276 episodes of care).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I created a unique ID for them and then merged the 240 patients back to the 276 episodes of care. However, when I do this, SAS recognises that the patients are the same on the newid variable, but it does not input the same value for the newid1 variable, which is the unique ID I have created (screen shot in attachment).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note – I start at 9132 for the newid1 variable as I plan to merge data with original unique IDs back to the bigger dataset with 14,000 episodes of care in which there are 9131 unique patients.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data=missing_ID out=missing_ID1 nodupkey;&lt;/P&gt;&lt;P&gt;by surname given_initial gender birth_date;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; missing_ID2;&lt;/P&gt;&lt;P&gt;set missing_ID1;&lt;/P&gt;&lt;P&gt;newid1+&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;newid=newid1+&lt;STRONG&gt;9132&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data= missing_ID2;&lt;/P&gt;&lt;P&gt;by surname given_initial gender birth_date;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data= missing_ID;&lt;/P&gt;&lt;P&gt;by surname given_initial gender birth_date;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; all_missing_merged;&lt;/P&gt;&lt;P&gt;merge missing_ID missing_ID2;&lt;/P&gt;&lt;P&gt;by surname given_initial gender birth_date;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Screen shot is in an attachment.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for our help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 06 May 2016 00:29:30 GMT</pubDate>
    <dc:creator>LauraF1</dc:creator>
    <dc:date>2016-05-06T00:29:30Z</dc:date>
    <item>
      <title>How do I create a unique ID based on four patient variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-unique-ID-based-on-four-patient-variables/m-p/268706#M310484</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to using SAS. I have a query about creating a unique ID for a group of patients that is based on a number of variables in SAS 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 276 episodes of care, in which the same patient may have presented multiple times. I have no unique ID for them and I would like to create one. The 276 episodes of care have been pulled out of 14,000 episodes in which there was a unique ID for those episodes but it is missing for the 276 episodes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variables I have to identify the patients are: surname, given initial, birth date and gender.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have done so far and where my problem is (code and screen shots below):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the 276 episodes of care I got rid of the duplicate patients based on the above variables (there are 240 patients in the 276 episodes of care).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I created a unique ID for them and then merged the 240 patients back to the 276 episodes of care. However, when I do this, SAS recognises that the patients are the same on the newid variable, but it does not input the same value for the newid1 variable, which is the unique ID I have created (screen shot in attachment).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note – I start at 9132 for the newid1 variable as I plan to merge data with original unique IDs back to the bigger dataset with 14,000 episodes of care in which there are 9131 unique patients.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data=missing_ID out=missing_ID1 nodupkey;&lt;/P&gt;&lt;P&gt;by surname given_initial gender birth_date;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; missing_ID2;&lt;/P&gt;&lt;P&gt;set missing_ID1;&lt;/P&gt;&lt;P&gt;newid1+&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;newid=newid1+&lt;STRONG&gt;9132&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data= missing_ID2;&lt;/P&gt;&lt;P&gt;by surname given_initial gender birth_date;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sort&lt;/STRONG&gt; data= missing_ID;&lt;/P&gt;&lt;P&gt;by surname given_initial gender birth_date;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; all_missing_merged;&lt;/P&gt;&lt;P&gt;merge missing_ID missing_ID2;&lt;/P&gt;&lt;P&gt;by surname given_initial gender birth_date;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Screen shot is in an attachment.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for our help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2016 00:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-unique-ID-based-on-four-patient-variables/m-p/268706#M310484</guid>
      <dc:creator>LauraF1</dc:creator>
      <dc:date>2016-05-06T00:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a unique ID based on four patient variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-unique-ID-based-on-four-patient-variables/m-p/268725#M310485</link>
      <description>&lt;P&gt;You can do this operation in a single step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=missing_ID;
by surname given_initial gender birth_date;
run;

data all_missing;
set missing_ID;
by surname given_initial gender birth_date;
newid1 + first.birth_date;
newid=newid1+9132;
drop newid1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 May 2016 02:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-unique-ID-based-on-four-patient-variables/m-p/268725#M310485</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-05-06T02:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a unique ID based on four patient variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-unique-ID-based-on-four-patient-variables/m-p/268729#M310486</link>
      <description>&lt;P&gt;Brilliant! Thank you very much, it works perfectly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2016 03:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-unique-ID-based-on-four-patient-variables/m-p/268729#M310486</guid>
      <dc:creator>LauraF1</dc:creator>
      <dc:date>2016-05-06T03:00:39Z</dc:date>
    </item>
  </channel>
</rss>

