Returns a character string that contains the value for a capture buffer.
| Category: | Character String Matching |
| Restriction: | Use with the PRXPARSE function. |
specifies a numeric variable with a value that is a pattern identifier that is returned by the PRXPARSE function.
is a numeric constant, variable, or expression that identifies the capture buffer for which to retrieve a value:
specifies the text from which to extract capture buffers.
data ReversedNames;
input name & $32.;
datalines;
Jones, Fred
Kavich, Kate
Turley, Ron
Dulix, Yolanda
;
data FirstLastNames;
length first last $ 16;
keep first last;
retain re;
if _N_ = 1 then
re = prxparse('/(\w+), (\w+)/');
set ReversedNames;
if prxmatch(re, name) then
do;
last = prxposn(re, 1, name);
first = prxposn(re, 2, name);
end;
run;
proc print data = FirstLastNames;
run;data old;
input name $60.;
datalines;
Judith S Reaveley
Ralph F. Morgan
Jess Ennis
Carol Echols
Kelly Hansen Huff
Judith
Nick
Jones
;
data new;
length first middle last $ 40;
keep first middle last;
re = prxparse('/(\S+)\s+([^\s]+\s+)?(\S+)/o');
set old;
if prxmatch(re, name) then
do;
first = prxposn(re, 1, name);
middle = prxposn(re, 2, name);
last = prxposn(re, 3, name);
output;
end;
run;
proc print data = new;
run;