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
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;
The PROPCASE command works on most words, but McFarlane, which has multiple capital letters, will fail.
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;
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.
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 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.