Date: Fri, 4 Jul 2003 09:53:17 +0100
Reply-To: Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Organization: Crawford Software Consultancy Limited
Subject: Re: pulling apart character variable
Hi Venky
have you a proposal that won't upcase the rest of the variable or wipe
it out, as might happen if the variable value is like
>>>>> Oregon State University (Osu) maths department
Is this an example for the v9 call prxchange() ?
Regards
Peter
Venky Chakravarthy <venky.chakravarthy@PFIZER.COM> writes
>On Wed, 2 Jul 2003 10:33:36 -0700, Kristie Beth <kristie_35_89@YAHOO.COM>
>wrote:
>
>>Hi SAS-L,
>>Maybe this question is too simple but I can't find a solution so am going
>to you for help, suggestions.
>>
>>I want to pull apart a character string where there are parentheses and
>replace the existing text with upcase letters. I want to use a function
>like substr but do not know what word position the parentheses are at as
>they vary from case to case.
>>
>>My strings are like so:
>>
>>Oregon State University (Osu)
>>Clinical Research Project (Crp)
>>University of California, Santa Barbara (Ucsb)
>>
>>Any help or suggestion are much appreciated!
>>
>>thanks! Kristie
>>
>>
>>
>>
>>---------------------------------
>>Do you Yahoo!?
>>The New Yahoo! Search - Faster. Easier. Bingo.
>
>
>Kristie,
>
>The SUBSTR function is special in that it can also be used on the left side
>of the equation unlike other functions. This property is useful in
>replacing a part of a string without creating a new variable. In your case,
>the solution can be:
>
>data _null_;
> infile cards truncover ;
> input @1 mystr $char50.;
> substr(mystr,index(mystr,"(")+1) = upcase(scan(mystr,-1,"(")) ;
> put mystr;
>cards;
>Oregon State University (Osu)
>Clinical Research Project (Crp)
>University of California, Santa Barbara (Ucsb)
>;
>
>Kind Regards,
>
>Venky
--
Peter Crawford
available for SAS consultancy contracts
|