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 (September 2009, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 29 Sep 2009 14:18:45 +0200
Reply-To:     Daniel Fernández <fdezdan@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Daniel Fernández <fdezdan@GMAIL.COM>
Subject:      Re: SAS Subset
Comments: To: Dominic Mitchell <mitchell.d@videotron.ca>
In-Reply-To:  <9413AFF7D95448109A1A31F4D3D4B378@dominic2>
Content-Type: text/plain; charset=ISO-8859-1

well done Dominic! I knew perl reg.expresion is a good candidate to solve this situation.

Daniel Fernández. Barcelona

2009/9/29 Dominic Mitchell <mitchell.d@videotron.ca>: > Hi Dave, > > Something like that would work > > > data test; > input part_num $; > cards; > ABC1234 > ABCD123 > 1551619 > abc6547 > a675argt > aghf1234 > ghf7654 > ; > > data sub; > set test; > if prxmatch('/^[A-Z]{3}[0-9]{4}\s*$/i',part_num); > proc print; > run; > > > ^[A-Z]{3} : the strings starts with 3 upper case letter > [0-9]{4}: it is followed by four digits > \s*$: the string can only be followed by blanks until the end of the length > of the variable > /i : ignore case > > Obs part_num > > 1 ABC1234 > 2 abc6547 > 3 ghf7654 > > > Dominic. > > > -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Dave > Smith > Sent: Monday, September 28, 2009 11:13 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: SAS Subset > > hi, > > I was wondering if someone can help me, > > I have a data set from which I want to subset a part of it based on a var > called part_num, > > if the first 3 characters of part_num are alphabets and the last 4 are > numeric then I want to output. for example, > > part_num > ABC1234 > ABCD123 > 1551619 > etc etc > > the output would only have ABC1234, is there a way to do it? > > Thanks > > Dave >


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