Hello,
I have dummy variable Var1 and Var2.
How will I remove the 2 in R862 so as to have R86 and R86 in both Var1 and Var2.
I will like to do this for all the unmatched e.g. C23 and C2357, E89 and E8996 etc. I have over 10,000 encounters my dataset with this issue.
Fname Lname Firstname Lastname Var1 Var2
John Doe John Do J124 J124
Pat Cut Patt Cot jr C23 C2357
Riley Jo Sr Rilly Joo R862 R86
Ellen Mee Elen Meey Sr. E89 E8996
@Reeza I want my output to be matched result for the two dummy variables. I will like to remove the extra numbers from each row. This is want I want my output to looks like.
Var1 Var2
J124 J124
C23 C23
R86 R86
E89 E89
Check the lengths of each variable and whichever is the smaller, use that and assign it to both variables.
Something like this perhaps:
if length(var1) < length(var2) then var2=var1;
else var1=var2;
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.