LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2005, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 8 Apr 2005 17:11:19 -0400
Reply-To:     Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject:      Re: Converting case..
Comments: To: K S <nsridhar@MEDAREX.COM>

On Fri, 8 Apr 2005 16:09:06 -0400, Sridhar, Kumar <nsridhar@MEDAREX.COM> wrote:

>Hi: > > I am trying to convert a variable (a string in uppercase) to >title case (like so: This Is A Test) and was wondering if any of you >could help me..

Hi, Kumar,

It is OK to stick with old and *reliable* version. Here is one way to emulate propcase() function. Tested in 8.2. Harry the Horse.

Cheers, Chang

data places; input place $ 1-40; cards; INTRODUCTION TO THE SCIENCE OF ASTRONOMY VIRGIN ISLANDS (U.S.) SAINT KITTS/NEVIS WINSTON-SALEM, N.C. SAS INSTITUTE ; run;

data _null_; set places; if not missing(place) then link PropCase; put place; return;

PropCase: /* 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. */ drop _:; length _len _flag _p 8 _c _tab $1; _tab = '09'x;

place =lowcase(place); _len = length(place); _flag = 1; do _p = 1 to _len; _c = substr(place,_p,1); if _flag then substr(place,_p,1) = upcase(_c); _flag = (index(' /-(.' || _tab, _c)>0); end; return; run;

/* on log Introduction To The Science Of Astronomy Virgin Islands (U.S.) Saint Kitts/Nevis Winston-Salem, N.C. Sas Institute */


Back to: Top of message | Previous page | Main SAS-L page