Hi Team,
I would like to know, if is possible to select the word in a specific interval string.
Ex: Variable name: Comments
I need select the words between PROCESS ORIGIN and FACTS.
PROCESS ORIGIN sas communities FACTS
PROCESS ORIGIN Google Inc FACTS
PROCESS ORIGIN Google FACTS
Thx !!!
data want(drop=_:);
input string&$100.;
length want $80;
retain _re;
if _n_=1 then
_re=prxparse('/\bprocess origin\b(.*)\bfacts\b/oi');
if prxmatch(_re, trim(string)) then
do;
want=prxposn(_re, 1, string);
end;
cards;
PROCESS ORIGIN sas communities FACTS
PROCESS ORIGIN Google Inc FACTS
PROCESS ORIGIN Google FACTS
Process Original Mix by Wehbba facts
blah PROCESS ORIGIN Google Inc FACTS
blah PROCESS ORIGIN Google Inc xxFACTS
blah PROCESS ORIGIN Google Inc FACTSxx
;
Please try
data want;
input string&$100.;
want=prxchange('s/(.*origin)(.*)(FACTS\s)/$2/i',-1,string);
cards;
PROCESS ORIGIN sas communities FACTS
PROCESS ORIGIN Google Inc FACTS
PROCESS ORIGIN Google FACTS
;
data want(drop=_:);
input string&$100.;
length want $80;
retain _re;
if _n_=1 then
_re=prxparse('/\bprocess origin\b(.*)\bfacts\b/oi');
if prxmatch(_re, trim(string)) then
do;
want=prxposn(_re, 1, string);
end;
cards;
PROCESS ORIGIN sas communities FACTS
PROCESS ORIGIN Google Inc FACTS
PROCESS ORIGIN Google FACTS
Process Original Mix by Wehbba facts
blah PROCESS ORIGIN Google Inc FACTS
blah PROCESS ORIGIN Google Inc xxFACTS
blah PROCESS ORIGIN Google Inc FACTSxx
;
Thank you!
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.