Hi Experts,
I am trying to use prxparse to match a pattern
data c;
pattern=prxparse('/abc|bcd|esd/');
position =prxmatch(pattern,' abc fgg rrt);
run;
now i have another table with column c1 as follows:
C1
abc
bcd
esd
so my question is here can we use column values directly into prxparse to define pattern
rather then manually typing each value.
My other concern is how to remove consecutive duplicate string in
lets say I have values as follows:
column1
steve steve is walking is walking
steve john steve john is walking
steve john steve john steve john
So i want mu output as
column1
Steve is walking
Steve John is walking
steve John
Please help me on this.
In case of more clarifications required please revert.
Regards,
Rohit
First question: build the pattern by concatenating words (hint: use string = catx("|", string, word) )
Second question:
data have;
input str :&$64.;
datalines;
steve steve is walking is walking
steve john steve john is walking
steve john steve john steve john
steve is is john steve
;
data want;
set have;
length oldStr newStr $64;
oldStr = str;
do i = 1 to 100;
newStr = prxchange("s/(\b\w+\b)(.*)(\1\s*)/\1\2/io", -1, oldStr);
if newStr = oldStr then leave;
oldStr = newStr;
end;
drop i oldStr;
run;
proc print; run;
First question: build the pattern by concatenating words (hint: use string = catx("|", string, word) )
Second question:
data have;
input str :&$64.;
datalines;
steve steve is walking is walking
steve john steve john is walking
steve john steve john steve john
steve is is john steve
;
data want;
set have;
length oldStr newStr $64;
oldStr = str;
do i = 1 to 100;
newStr = prxchange("s/(\b\w+\b)(.*)(\1\s*)/\1\2/io", -1, oldStr);
if newStr = oldStr then leave;
oldStr = newStr;
end;
drop i oldStr;
run;
proc print; run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.