Functions and CALL Routines |
Converts all words in an argument to proper case.
PROPCASE(argument <,delimiters>)
|
-
argument
-
specifies a character constant, variable,
or 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. |
In a DATA step,
if the PROPCASE function returns a value to a variable that has not previously
been assigned a length, then that variable is given a length of 200 bytes.
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 results of the PROPCASE function depend directly on the translation
table that is in effect (see TRANTAB System Option) and indirectly
on the ENCODING System Option and the LOCALE System
Option in
SAS National Language Support (NLS): Reference Guide.
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.
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 : $20. CapsName : $20.;
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;
Output Showing the Results of Using PROPCASE with a Second Argument
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
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.