Date: Mon, 19 Jan 2009 11:32:16 -0500
Reply-To: SAS_learner <proccontents@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: SAS_learner <proccontents@GMAIL.COM>
Subject: Re: Trim data by x characters
In-Reply-To: <1072d0f3-2315-43c4-ac19-e8e9e50cd786@r15g2000prh.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Hello jaheuk,
How would your solution would work if there no delimter in the search string
(Just thinking of the possibilites) , Say like your example Var2 values are
Var1 Var2
AA code12thedescription
BB cod4thedescription
CC codethedescriptiondone
I think If Origonal Poster sends us How the description strings are then we
can write better code snipnet .
thanks
SL
On Mon, Jan 19, 2009 at 4:56 AM, jaheuk <hejacobs@gmail.com> wrote:
> DATA STEP solutions:
> ---------------------------------
>
> DATA one;
> input var1 $ var2 $ 30. ;
> cards;
> AA
> ;
> RUN;
>
> DATA two;
> SET one;
> var3 = substr(var2,1,index(var2,'_')-1);
> RUN;
> *******************************************************;
>
> DATA one;
> input var1 $ var2 $ 30. ;
> cards;
> AA 12_thedescription
> BB 456987_thedescription
> ;
> RUN;
>
> DATA two;
> SET one;
> var3 = input(substr(var2,1,index(var2,'_')-1),best.);
> RUN;
>
>
>
>
> Regards,
> H.
>
>
>
>
> On 19 jan, 09:48, mikeymay <mikey...@gmail.com> wrote:
> > I have a dataset that holds a variable with a prefix code prior to the
> > description.
> >
> > I want to trim the variable by the number of characters the prefix
> > code has but the prefix code can be 4, 5, 6, 7 or 8 characters long.
> >
> > Is there a way of trimming the data using a procedure?
> >
> > Thanks
>
|