Date: Fri, 4 May 2007 11:12:19 -0400
Reply-To: "data _null_;" <datanull@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "data _null_;" <datanull@GMAIL.COM>
Subject: Re: PRX_____ functions and macro variables
In-Reply-To: <1178287187.248320.190610@p77g2000hsh.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
FINDC works nicely.
I'm not sure if using the constant for <startpos> is better or worse
that using VLENGTH or LENGTH or a more conservative constant.
data _null_;
attrib text length=$100;
text = 'Text with split \ characters at \ the end \
\ \ ';
f1 = findc(text,' \','v',-length(text));
trim = substr(text,1,1+findc(text,' \','v',-32767));
put (_all_) (=/);
run;
On 5/4/07, Scott D. <scottdiegel@gmail.com> wrote:
> I need to use the PRXMATCH function with the value of a macro variable
> as one of the match characters. I have text that looks like this, for
> example:
>
> Text with split \ characters at \ the end \
> \ \
>
> And I want to trim off everything after the end of the real text,
> which in this case would be everything after the word "end." The
> PRXMATCH call in the code below works if the split character (a
> backslash) is hard-coded in the call, but not if I replace the "\\"
> with "&splitc" which is what I want, as the split character is a user-
> specified parameter in a macro.
>
>
> %let splitc = \;
>
> data newrep2;
> set newrep;
> pos = prxmatch('/[^\s\\](\s*\\?)*$/', comment);
> comment = substr(comment, 1, pos);
> run;
>
|