Converts all words in an argument to proper case
Category: Character
PROPCASE ( argument <, delimiter (s) >)
argument
specifies any SAS character expression.
delimiter
specifies one or more delimiters that are enclosed in quotation marks. The default delimiters are blank, forward slash, hyphen, open parenthesis, period, and tab.
Tip: If you use this argument, then the default delimiters, including the blank, are no longer in effect.
The PROPCASE function copies a character argument and converts all uppercase letters to lowercase letters . It then converts to uppercase the first character of a word that is preceded by a blank, forward slash, hyphen, open parenthesis, period, or tab. PROPCASE returns the value that is altered .
If you use the second argument, then the default delimiters are no longer in effect.
The following example shows how PROPCASE handles the case of words:
data _null_; input place $ 1-40; name=propcase(place); put name; datalines; INTRODUCTION TO THE SCIENCE OF ASTRONOMY VIRGIN ISLANDS (U.S.) SAINT KITTS/NEVIS WINSTON-SALEM, N.C. ; run;
SAS writes the following output to the log:
Introduction To The Science Of Astronomy Virgin Islands (U.S.) Saint Kitts/Nevis Winston-Salem, N.C.
This example shows that you can use the PROPCASE function inside other functions:
data _null_; x=lowcase('THIS IS A DOG'); y=propcase(x); z=propcase(lowcase('THIS IS A DOG')); put x=; put y=; put z=; run;
SAS writes the following output to the log:
x=this is a dog y=This Is A Dog z=This Is A Dog
data _null_; string1='VERY RARE BOOKS'; /* PROPCASE converts the words in string1 to proper case. */ case1=propcase(string1); put case1=; /* TRANWRD searches string1 for the word VERY and */ /* replaces VERY with a blank. PROPCASE converts */ /* the words in string1 to proper case. */ case2=propcase(tranwrd(string1, 'VERY', ' ')); put case2=; run;
SAS writes the following output to the log:
case1=Very Rare Books case2=Rare Books
The following example uses a blank, a hyphen and a single quotation mark as the second argument so that names such as O'Keeffe and Burne-Jones are written correctly.
options pageno=1 nodate ls=80 ps=64; data names; infile datalines dlm='#'; input CommonName : . CapsName : .; PropcaseName=propcase(capsname, " -'"); datalines; Delacroix, Eugene# EUGENE DELACROIX O'Keeffe, Georgia# GEORGIA O'KEEFFE Rockwell, Norman# NORMAN ROCKWELL Burne-Jones, Edward# EDWARD BURNE-JONES ; proc print data=names noobs; title 'Names of Artists'; run;
Names of Artists 1 CommonName CapsName PropcaseName Delacroix, Eugene EUGENE DELACROIX Eugene Delacroix O'Keeffe, Georgia GEORGIA O'KEEFFE Georgia O'Keeffe Rockwell, Norman NORMAN ROCKWELL Norman Rockwell Burne-Jones, Edward EDWARD BURNE-JONES Edward Burne-Jones
Functions:
'UPCASE Function' on page 866
'LOWCASE Function' on page 641