|
I believe in 6.12 the RXPARSE argument must start with a grave aka backquote
(`)
6.12 Prelim RX docs are at ftp://ftp.sas.com/pub/neural/rx612.txt
--
Richard DeVenezia - SAS Macros and AF Tools
http://www.devenezia.com
"Chakravarthy, Venky" <Venky.Chakravarthy@PFIZER.COM> wrote in message
news:2195003E3380D411965D00508B60994803909BE7@aascooby.research.aa.wl.com...
> Mike,
>
> I ran your code (earlier version and the current) in v6.12. I expected the
> code to work, since the RX functions were already experimental in v6.11
and
> v6.12. Although it ran without ERROR messages, it generated NOTES with
> "Invalid first argument" to the CALL RXCHANGE portion and thus did not
> produce the expected results. Pasted, below my sig, is the relevant
portion
> of the log from v6.12.
>
> I could not find any documentation on the RX functions specific to V6.12.
I
> later learnt, from SAS tech support, that the preliminary documentation
> provided around experimental status time, has since been incorporated into
> the v7/v8 production docs. This is, of course, with updates for the bugs
> fixed. So, if v6.12 has the RX bugs (that were later fixed), it could
> explain the log.
>
> There appears to be one outstanding bug associated with the RX (purported
to
> be fixed in V9). If the source and target variables are the same, the
> existing value is completely replaced by the TO string in the RXPARSE.
This
> is documented (see
> http://www.sas.com/service/techsup/unotes/SN/005/005186.html).
>
> Thanks for introducing the RX functions. These and other v8 functions
should
> come in handy when this shop moves 8.2 to production. This should happen
> soon.
>
> Kind Regards,
>
> Venky
> #****************************************#
> # E-mail: venky.chakravarthy@pfizer.com #
> # swovcc@hotmail.com #
> # Phone: (734) 622-1963 #
> #****************************************#
>
> 1 data _null_;
> 2 length old new $ 32;
> 3 if _n_ = 1 then rx = rxparse
> 4 (" <: ^' '> <' ' ' '*> <^' ' :> TO =1 ',' =3 ");
> 5 retain rx;
> 6 input old $char32.;
> 7 call rxchange (rx,1,trim(left(old)),new);
> 8 put / 'OLD: ' old $char32. / 'NEW: ' new $char32.;
> 9 cards;
>
> NOTE: Invalid first argument to function RXCHANGE at line 7 column 8.
>
> OLD: one blank
> NEW:
>
RULE:----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
> ---+----8----+----9--
> 10 one blank
> OLD=one blank NEW= RX=1 _ERROR_=1 _N_=1
> NOTE: Invalid first argument to function RXCHANGE at line 7 column 8.
>
> <rest of log snipped>
>
> -----Original Message-----
> From: Mike Rhoads [mailto:RHOADSM1@WESTAT.COM]
> Sent: Monday, December 03, 2001 8:50 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: Parsing a string
>
>
> I wound up putting together a slightly different version of the program
that
> handles multiple replacements. (Recall that the original question was
about
> replacing strings of 2 or more blanks with a comma, while leaving single
> blanks alone.) The revised program is below. A few notes on the pattern:
> < > tags a part of the matching pattern, so that the part of the string
that
> is matched by that part of the pattern can be used in the replacement
> expression (after the keyword TO)
> =1 refers to the part of the string matched by the first tagged part of
the
> pattern
> * 0 to many occurrences of what immediately precedes it
> + 1 to many occurrences of what immediately precedes it
> ( ) grouping
> ^ any character EXCEPT those in the immediately following string
>
> Mike Rhoads
> Westat
> RhoadsM1@Westat.com
>
>
> data _null_;
> length old new $ 32;
> if _n_ = 1 then rx = rxparse (
> /* Optional leading blanks followed by 1+ nonblanks */
> "< ' '* (^' ')+ >" ||
> /* Followed by 2 or more blanks */
> "< ' ' ' '* >" ||
> /* Replace with the first part unchanged, then a comma */
> "TO =1 ',' "
> );
> retain rx;
> input old $char32.;
> call rxchange (rx,999,trim(old),new);
> put / 'OLD: ' old $char32. / 'NEW: ' new $char32.;
> cards;
> 1 2 3 4 5
> 1 1 1 1 1
> 2 2 2 2 2
> 22 22 22 22 22
> 3 3 33 3 333
> 3 3 33 3 333
> one two three endofline
> three two one zero
> one blank
> one blank
> two blanks
> three blanks
> four blanks
> two blanks
> another, string.
> ;
> run;
|