Hi everyone,
I was given a dataset with first name and last name variables and asked to concatonate these and then order the full name alphabetically. I have managed to concatonate the names but I am struggling to order the full name. Hopefully the example below will clear things up.
Data I had:
fname sname
Jim Smith
Tom Bell
Data currently:
fullname
JimSmith
TomBell
Data I need:
fullname2
hiiJmmSt
BellmoT
Apologies if this has been answered but I have not found anything on my searches!
Thanks in advance
Data currently;
input fullname $20.;
datalines;
JimSmith
TomBell
;
data want;
set currently;
array t(50) $ _temporary_;
call missing(of t(*));
do _n_=1 to length(strip(fullname));
t(_n_)=lowcase(char(fullname,_n_));
end;call sortc(of t(*));newname=cats(of t(*));run;
data matching with another work data set.
Hmm. "Tim Mott" and "Tom Mitt" will not match in name form, but will match in sorted anagram form. That could be interesting.
@skibur I think your question has been answered. Please close the thread. It's way too simple question
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.