PROPCASE Function


PROPCASE Function

Converts all words in an argument to proper case

Category: Character

Syntax

PROPCASE ( argument <, delimiter (s) >)

Arguments

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.

Details

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.

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 Other Functions

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 

Example 3: Using PROPCASE with Other Functions: Another Example

 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 

Example 4: 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 : . 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; 
Output 4.33: Output Showing the Results of Using PROPCASE with a Second Argument
start example
 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 
end example
 

See Also

Functions:

  • 'UPCASE Function' on page 866

  • 'LOWCASE Function' on page 641




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net