| Date: | Mon, 24 Jan 2005 13:07:52 -0500 |
| Reply-To: | Mike Rhoads <RHOADSM1@WESTAT.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Mike Rhoads <RHOADSM1@WESTAT.COM> |
| Subject: | Re: Looking for something equivalent to RTRIM |
|
| Content-Type: | text/plain |
|---|
Richard,
Very neat!
The 9.1.3 documentation suggests that PRXMATCH is now "smart" enough that
the expression compilation is only done once when it is passed as a
constant. Do you know whether or not that alleviates the memory problems
that you referred to in your earlier posting?
Mike Rhoads
Westat
RhoadsM1@Westat.com
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Richard
A. DeVenezia
Sent: Friday, January 21, 2005 9:36 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Looking for something equivalent to RTRIM
Chad Webb wrote:
> My problem is that what I was told and what it true are two different
> things. A policy can have multiple "alpha-numeric" 3 byte prefix
> separated by a space and then followed by the 10 digit id. Examples:
> 'AAP 0011223344', 'AP1 00A 1234567890'
>
> I first thought to use compress and remove the characters and spaces,
> but I would be wrong because a prefix could have a number.
Sounds like a job for PRX.
This select only computes the 'number' when the 'id' matches the regular
expression describing the expected value construct.
-------------------------
data foo;
length id $20;
input id &;
cards;
AAP 0011223344
AP1 00A 1234567890
AP1 00A 123456789O
AP1 00A 12345678901
run;
ods listing;
options nocenter;
data _null; _null=.; run;
proc sql noprint;
create table two as
select case
when prxmatch (dual.prx, id) then substr (id,length(id)-9)
else 'nonconform'
end as number
from foo
, (select prxparse("/ \d{10}\s*$/") as prx from _null) as dual
;
quit;
-------------------------
See July 23, 2004 thread "How to use RXPARSE in SQL" for a similar and
explanatory post.
Richard A. DeVenezia
|