Date: Thu, 26 Jul 2001 09:11:17 -0400
Reply-To: Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject: Re: RXPARSE, RXMATCH : storing pattern matches in sas variables
Content-Type: text/plain; charset="iso-8859-1"
Richard,
I didn't have any better luck. I am wondering if it is a documentation
glitch, and they really mean "pseudovariables" rather than actual DATA step
variables get assigned values. For instance, if you are doing an RXCHANGE
and specify CName=<^'@.'*> in the first part of your pattern and =CName
somewhere after the TO, it will correctly do the substitution within the
expression.
This would actually give you a way to do what you want with the parsing
routines, particularly if all you need to extract is the company name. It
works because CName is the final argument to CALL RXCHANGE, however, not
because CName is used to label the tagged expression.
DATA Temp;
INFILE CARDS TRUNCOVER;
RETAIN Rxptr1;
KEEP Address CName;
LENGTH Address $ 80 CName $ 32 ;
IF _N_ = 1 THEN Rxptr1 = RXPARSE
("^'@.'* '.' ^'@.'* '@' CName=<^'@.'*> '.' ^'@.'* TO =CName");
INPUT Address;
CALL RXCHANGE (Rxptr1,1,Address,CName);
PUT _ALL_;
CARDS;
firstname.lastname@company.com
Richard.Patterson@SOLVAY.COM
John.Doe@Anonymous.org
RUN;
Mike Rhoads
Westat
RhoadsM1@Westat.com
-----Original Message-----
From: Patterson, Richard [mailto:Richard.Patterson@SOLVAY.COM]
Sent: Thursday, July 26, 2001 6:12 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: RXPARSE, RXMATCH : storing pattern matches in sas variables
hi folks,
I need to process email addresses in the format -
firstname.lastname@company.com. I can do this useing index, substr etc but
would like to use RXPARSE and RXMATCH. I need to matches to be as flexible
as possible.
I need to extract the company name from the email address. I can work out
the pattern matching ok using RXPARSE and RXMATCH. However my problem is
that I do not know how to assign the resulting matched string(s) to a
variable for later use (ie the company name). In Perl I would surround my
pattern with brackets and the first resulting match is stored in $1. The
information I need seems to be in the RXPARSE Online help section under "Tag
Expression" but there is no example. In SAS you surround the pattern with <>
and the result should be stored in sas variable _1, but I am having no
success.
Anybody have an example of storing the result of a matching expression in a
sas variable ?
Thanks, any help much appreciated.
Richard Paterson