Date: Thu, 14 May 2009 22:01:02 -0400
Reply-To: msz03@albany.edu
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Zdeb <msz03@ALBANY.EDU>
Subject: Re: Text Manipulation
Content-Type: text/plain;charset=iso-8859-1
hi ... using Ya's COMPRESS with a tweak ('d' for all numerals), I think this also works
no digits, no compression, no room for OTHER to be added to the name
(yes, 1 or more digits in a name would screw it up)
data have;
input name $;
cards;
John
Jones
5648
Paul
78900
Julie
;
data need;
set have;
name = left(compress(name,,'d') || 'Other');
run;
proc print data=need;
run;
--
Mike Zdeb
U@Albany School of Public Health
One University Place
Rensselaer, New York 12144-3456
P/518-402-6479 F/630-604-1475
> Use compress to get rid of all numbers, if left with a blank string,
> the it was a string of number, then replace it:
>
> data have;
> input name $;
> cards;
> John
> Jones
> 5648
> Paul
> 78900
> Julie
> ;
>
> data need;
> set have;
> if compress(name,'0123456789')='' then name='Other';
> run;
>
> proc print;
> run;
>
> Obs name
>
> 1 John
> 2 Jones
> 3 Other
> 4 Paul
> 5 Other
> 6 Julie
>
>
> On Thu, 14 May 2009 17:29:02 -0700, saurabh <saurabhkdas@GMAIL.COM> wrote:
>
>>Hello All,
>>
>>I have a dataset , and its has a column called Name - Type Text.
>>
>>This column has the following values
>>Name
>>---------
>>John
>>Jones
>>5648
>>Paul
>>78900
>>Julie
>>...
>>...
>>...
>>
>>
>>
>>What I wish is to change all those name which are numeric to a value =
>>"Others".
>>
>>help needed.
>>
>>thanks
>>SD
>
|