BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Thoney
Calcite | Level 5

Hi All,

I have a question about name casing. I've done a quick search on the forums but couldn't find anything initially, so I apologise if this question has been asked before, but I was wondering if anyone had any particular method for proper name casing?

By this I mean, you have all names in say lower case in a dataset containing customer names for example. You need to put together an email or mailing campaign to these customers, however you do not want to offend any of your customers by trying to proper case their surnames, which usually disregards second capitalisation (with surnames like O'Toole or McFarlane)

With my current knowledge I could easily format names so they look like;

Peter Mcfarlane

Robert O'toole

Or;

PETER MCFARLANE

ROBERT O'TOOLE

but I was wondering if anyone had an ingenious way of producing the proper case like;

Peter McFarlane

Robert O'Toole

I mean, is it a case that I'm going to need to set up a custom string of IF statements to check the string for certain characters? (this is what I would do I guess) Or, is there another ingenious and simple way to nail this type of issue?

~ Tom

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

You don't get that "out-of-the-box" with Base SAS. If you have the Data Quality Server licensed then you could easily get it by using DQ functions for casing SAS(R) 9.3 Data Quality Server Reference

A compromise could be to use Propcase() and then some additional logic for defined cases as done in below sample code.

data sample;

  input name_string $40.;

  Name_Prop=propcase(name_string);

  Name_RegEx=prxchange("s/\bmc([[:alpha:]])/Mc\U\1/oi",-1,Name_Prop);

  Name_RegEx=prxchange("s/(?<=\b[[:alpha:]]')([[:alpha:]])/\U\1/oi",-1,Name_RegEx);

  datalines;

peter mcfarlane

claudia schiffer

robert o'toole

;

run;

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

The PROPCASE command works on most words, but McFarlane, which has multiple capital letters, will fail.

--
Paige Miller
Patrick
Opal | Level 21

You don't get that "out-of-the-box" with Base SAS. If you have the Data Quality Server licensed then you could easily get it by using DQ functions for casing SAS(R) 9.3 Data Quality Server Reference

A compromise could be to use Propcase() and then some additional logic for defined cases as done in below sample code.

data sample;

  input name_string $40.;

  Name_Prop=propcase(name_string);

  Name_RegEx=prxchange("s/\bmc([[:alpha:]])/Mc\U\1/oi",-1,Name_Prop);

  Name_RegEx=prxchange("s/(?<=\b[[:alpha:]]')([[:alpha:]])/\U\1/oi",-1,Name_RegEx);

  datalines;

peter mcfarlane

claudia schiffer

robert o'toole

;

run;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Its not even that consistent unfortunately.  If you have names from further afield there is different regional variations etc: http://en.wikipedia.org/wiki/Capitalization#Sentence_case_versus_title_case

My suggestion, find out what is "required" at output and what is actually stored currently and see if there is a compromise to be had, e.g. all upcase or something.  You might also want to remove identifiers completely e.g de-identification.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2133 views
  • 6 likes
  • 4 in conversation