Date: Fri, 23 Dec 2011 22:16:35 -0500
Reply-To: Finto Antony <fintoa@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Finto Antony <fintoa@GMAIL.COM>
Subject: Re: Removing a delimiter in string
In-Reply-To: <201112240053.pBNLDPmt011660@waikiki.cc.uga.edu>
Content-Type: text/plain; charset=windows-1252
Try this:
data have; length food $ 20;
input food price;
food_new = trim(scan(food, 1, '_'))||"_"||scan(food, 2, '_');
datalines;
_rice__patty .29
_rice_bread .30
mango_peanut_ .70
_mango_tomato_ .50
salad_pasta .99
;
run;
there might be other methods.
Finto
On Fri, Dec 23, 2011 at 7:53 PM, Loveisdifferent
<tano.tano.2008@gmail.com>wrote:
> Hey folks I need some help on removing a delimeter '_' in a string .I have
> thought of a combination of substr and scan functions in order to get the
> food variable with only 1 delimeter ex rice_patty;Thanks for any suggestion
> and Merry christmas;;
>
> data have;
> input food price;
> datalines;
> _rice__patty .29
> _rice_bread .30
> mango_peanut_ .70
> _mango_tomato_ .50
> salad_pasta .99
> ;
> data want;
> input food price;
> datalines;
> rice_patty .29
> rice_bread .30
> mango_peanut .70
> mango_tomato .50
> salad_pasta .99
> ;
>
--
-------------------------------------------------------
Finto Antony
Warnell School of Forestry and Natural Resources
University of Georgia, Athens, GA-30602
Office: 706-542-7587
----------------------------------------------------------------------------------------------------------------
**
**
*“May be sometimes it’s the questions that are biased, not the answers”*
|