Hi, 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. 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. The variables I have to identify the patients are: surname, given initial, birth date and gender. What I have done so far and where my problem is (code and screen shots below): 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). 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). 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. Code: proc sort data=missing_ID out=missing_ID1 nodupkey; by surname given_initial gender birth_date; run; data missing_ID2; set missing_ID1; newid1+1; newid=newid1+9132; run; proc sort data= missing_ID2; by surname given_initial gender birth_date; run; proc sort data= missing_ID; by surname given_initial gender birth_date; run; data all_missing_merged; merge missing_ID missing_ID2; by surname given_initial gender birth_date; run; Screen shot is in an attachment. Thanks in advance for our help!
... View more