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 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 27 Apr 2009 16:25:07 -0500
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: Extract part of a variable
Comments: To: Michael Bryce Herrington <mherrin@g.clemson.edu>
In-Reply-To:  <e52cf8710904271400n31bd5a87j59d77d955024adb2@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

You might want to clarify what you mean by 'number extracted from var1'. I will assume you mean the numeric portion after CLM (and sometimes after CLMC); is there a better rule? Is it always clm##### ? Is the one clmc-7500 an exception, or a typo, or a consistent result (is neg. always clmc ?)

data racetype; format var1 $15.; input var1 $; datalines; clm2500 clm12500 clm7500n2l clm20000n1l clm15000c clmc-7500 clm8000b clm7500n2y ; run;

data want; set racetype; price = prxchange('s/(clm[c]?)([-]?\d+)(.*)/$2/',1,var1); run;

-Joe

On Mon, Apr 27, 2009 at 4:00 PM, Michael Bryce Herrington < mherrin@g.clemson.edu> wrote:

> Hey, I have variable that takes values like below. I would like to make a > new variable (price) that equals the number extracted from var1. Would you > help me with the commands to do this. Thanks. > > * > > data* racetype; > > input var1 $; > > datalines; > > clm2500 > > clm12500 > > clm7500n2l > > clm20000n1l > > clm15000c > > clmc-7500 > > clm8000b > > clm7500n2y > > ; > * > > run*; > > -- > Bryce Herrington > Clemson University > 111 Briar Lane > Central, SC 29630 > mherrin@g.clemson.edu > (863) 258-4758 >


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