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 (February 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 18 Feb 2009 19:20:04 -0500
Reply-To:   Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject:   Re: RX PARSE question (SAS 9.2)
Comments:   To: ezra.barzilay@GMAIL.COM

On Wed, 18 Feb 2009 14:52:24 -0800, Ezra Barzilay <ezra.barzilay@GMAIL.COM> wrote:

>New to REGEX and ignorant of PERL syntax (and thus PRX Functions), I >am (slowly) learning how to use the RX Functions that SAS provides. > >I am a bit stuck with the following: I am trying to identify a pattern >that starts with an optional "AAC" or "G", an optional dash, followed >by a 0 or 9, a number between 0 and 9 another dash and 4 (but no more) >alphanumeric characters. ... hi, Ezra, below is my try. I found that in 9.2, sas rx's are deprecated. But you can see rxparse function documentation in 9.1 at http://tinyurl.com/c9lftm or http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a000331192.htm another documentation still around is available at: ftp://ftp.sas.com/pub/neural/rx612.txt . ran on 9.2 on windows. cheers, chang

/* optional "AAC" or "G", an optional dach ("-"), followed by a digit (either 0 or 9), another digit (any), another dash, and no more than 4 alphanumeric characters */ %let an = a-zA-Z0-9; data _null_; retain prx "/(AAC|G)?-?[09]\d-[&an]{4}\b/" rx "{'AAC'|'G'} {'-'} $'09' $d '-' $'&an' $2 $2 $2 (^2|@0)"; infile cards firstobs=2; input var $char20.; prxMatched = ifc(prxmatch(prx, var), "Y", "N"); rxMatched = ifc(rxmatch(rx, var), "Y", "N"); put prxMatched= rxMatched= var=; cards; ----+----1----+----2 01-A2345 01-A234 5 01-A234 AAC-99-ABCD E ; run; /* on log NOTE: The RXSTYLE, RXPATTERN, RXPATMOD, RXNEXT, and RXSHOW functions are unsupported. Consider using the PRX functions instead. prxMatched=N rxMatched=N var=01-A2345 prxMatched=Y rxMatched=Y var=01-A234 5 prxMatched=Y rxMatched=Y var=01-A234 prxMatched=Y rxMatched=Y var=AAC-99-ABCD E */


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