BookmarkSubscribeRSS Feed
lyton80
Obsidian | Level 7

Hi all,

I am looking for an efficient way of extracting the initials of a name. For example:

Benjamin J. Lincoln -> BJC

Andrew Benson Jones -> ABJ

L. Michael Andersson Curt -> LMAC

I will be glad for the assistance.

Thanks

8 REPLIES 8
PaigeMiller
Diamond | Level 26

If you can be sure that the first letter of each name is always capitalized, it would be pretty easy to use the COMPRESS function to strip out lower case letters and non-alphabetic characters.

--
Paige Miller
lyton80
Obsidian | Level 7

Great...that works just fine! Thanks!

ballardw
Super User

Do you have any names like:

Otto Van Dyke, where Van Dyke is the last name? Would you want OVD or OV?

or Miguel De La Cruz, De La Cruz being the last name?

PaigeMiller
Diamond | Level 26

ballardw wrote:

Do you have any names like:

Otto Van Dyke, where Van Dyke is the last name? Would you want OVD or OV?

or Miguel De La Cruz, De La Cruz being the last name?

Or how about former White House Press Secretary Jerald terHorst, who insisted that the first "t" in "terHorst" was not capitalized? Smiley Wink

--
Paige Miller
ballardw
Super User

Not long ago I had to match children's names out of a data system where there was single name field. There was not set order for first name, middle name or initial or last names; suffixes such as Junior or Jr, Second or II or Third III could be any where in the field; last names of both mother and father could be present with  or without hyphens; and names like Van Dyke, al Allassi, De La Cruz and more odd constucts. So when I see a relatively unstructured request about names I cringe and ask what some people may consider odd questions.

Haikuo
Onyx | Level 15

For 's scenario, it seems no easy way out unless to build a dictionary. It is a lot simpler to deal with Mr. 'Jerald terHorst', we just need to PROPCASE first, then COMPRESS Smiley Happy

PaigeMiller
Diamond | Level 26

PROPCASE gives the wrong result for Jerald terHorst, who insists the first letter "t" in his last name is not capitalized, and the "H" in his last name is capitalized.

--
Paige Miller
skillman
SAS Employee

SAS Data Management has a name parse node which uses a known name dictionary and can parse a one field name input into multiple name tokens (name_prefix, first_name, middle_name, family_name, name_suffix). Then you could take the first initial of each using an expression node.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 3623 views
  • 3 likes
  • 5 in conversation