SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Extracting initials of a full name

Reply
Occasional Contributor
Posts: 15

Extracting initials of a full name

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

Trusted Advisor
Posts: 1,612

Re: Extracting initials of a full name

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.

Occasional Contributor
Posts: 15

Re: Extracting initials of a full name

Great...that works just fine! Thanks!

Super User
Posts: 10,497

Re: Extracting initials of a full name

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?

Trusted Advisor
Posts: 1,612

Re: Extracting initials of a full name

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

Super User
Posts: 10,497

Re: Extracting initials of a full name

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.

Respected Advisor
Posts: 3,124

Re: Extracting initials of a full name

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

Trusted Advisor
Posts: 1,612

Re: Extracting initials of a full name

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.

SAS Employee
Posts: 85

Re: Extracting initials of a full name

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.

Ask a Question
Discussion stats
  • 8 replies
  • 1236 views
  • 3 likes
  • 5 in conversation