PROPCASE Function

Converts all words in an argument to proper case.

Category: Character
Restriction: I18N Level 2 functions are designed for use with SBCS, DBCS, and MBCS (UTF8).

Syntax

PROPCASE(argument <,delimiters> )

Required Argument

argument

specifies a character constant, variable, or expression.

Optional Argument

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.

Details

Length of Returned Variable

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 the length of the first argument that is passed to PROPCASE.

The Basics

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 in SAS National Language Support (NLS): Reference Guide) and indirectly on the ENCODING and the LOCALE system options.

Examples

Example 1: Changing the Case of Words

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.

Example 2: Using a Second Argument with PROPCASE

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.
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
Output Showing the Results of Using PROPCASE with a Second Argument

See Also