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

Nobody mentioned pattern matching? Impress your friends at DM with:

data _null_;

str = "capitalize this";

Cstr = prxchange("s/^(.)/\u\1/o", 1, str);

put Cstr;

run;

PG

PG
data_null__
Jade | Level 19

That's the "correct answer".

PGStats
Opal | Level 21

Beware of solutions that do not work with accented characters. Compare :

data _null_;

retain MATCHstr RANKstr UPCASEstr PROPCASEstr "évariste Galois";

MATCHstr = prxchange("s/^(.)/\u\1/o",1,MATCHstr);

if rank(substr(RANKstr,1,1)) in (97:122) then

    substr(RANKstr,1,1)=byte(rank(substr(RANKstr,1,1))-32);

substr(UPCASEstr,1,1) = UPCASE(substr(UPCASEstr,1,1));

substr(PROPCASEstr,1,1) = PROPCASE(substr(PROPCASEstr,1,1));

put _ALL_ ;

run;

MATCHstr=Évariste Galois RANKstr=évariste Galois UPCASEstr=Évariste Galois

PROPCASEstr=Évariste Galois _ERROR_=0 _N_=1

PG

PG
jakarman
Barite | Level 11

An beware of the assumption of 1-byte = 1 character it is something many people learned and thinking it is true.

We are living in the age of Unicode (UTF-8) word excel html are using that.   Just old dinosaurusses are forgetting this. 
If you like to dig into that area of I18N see:

SAS(R) 9.4 National Language Support (NLS): Reference Guide, Second Edition

---->-- ja karman --<-----

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 18 replies
  • 12279 views
  • 14 likes
  • 8 in conversation