Show less
You need a way to determine whether a tentative new name has already been established for another person.
Show us the code (as a complete data step, or complete proc sql) that you are currently using - USING THE
OR
ICONS. That is essential to developing code to detect duplicates.
data emp1; set emp;
length name $70.;
middle_name2=substr(middle_name,1,1);
name_MI=trim(last_name)||", "||trim(first_name)||" "||trim(middle_name2);
first_name_i=scan(first_name,1);
name=trim(last_name)||", "||trim(first_name_i);
run;
I have a base data that was set up already as (Lastname, Firstname middle initial like Smart, Johnson L).
Don't bother making the NAME unique. Create an ID variable that is unique.
Something like:
data want;
set have;
id+1;
new_name = catx(', ',last_name,catx(' ',first_name,middle_initial));
run;
Then use their ID when combining the names with other data you have about them.
@Astounding's suggestion is good for the current situation, assuming no department currently has two people with the same name.
But people change departments - and much less frequently they change names. Either the identifier will remain fixed, but lose informational value (so why use name & dept to begin with?) - or it will be modified to follow the employee's changes, requiring a table of links between old and new identifiers.
There will be blood.
@mkeintz wrote:
@Astounding's suggestion is good for the current situation, assuming no department currently has two people with the same name.
But people change departments - and much less frequently they change names. Either the identifier will remain fixed, but lose informational value (so why use name & dept to begin with?) - or it will be modified to follow the employee's changes, requiring a table of links between old and new identifiers.
There will be blood.
Sounds like you may have bitten by the same things that I have. Including the "new database implementation will use new identifiers" headache.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.