Previous Page | Next Page

Functions and CALL Routines

PROPCASE Function



Converts all words in an argument to proper case.
Category: Character
Restriction: I18N Level 2

Syntax
Arguments
Details
Length of Returned Variable
The Basics
Examples
Example 1: Changing the Case of Words
Example 2: Using PROPCASE with a Second Argument
See Also

Syntax

PROPCASE(argument <,delimiters>)

Arguments

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.

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 a length of 200 bytes.


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


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 PROPCASE with a Second Argument

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

See Also

Functions:

UPCASE Function

LOWCASE Function

Previous Page | Next Page | Top of Page