Hi all,
I'm looking to perform a search for a string and a number based on a template ( variations) this way :
%let quant=[quantity0,quantity1,quantity2,quantity3,quantity4,quantity5,quantity6,quantity7,quantity8];
%let fruits=[apples, pears];
%let fruit=[apple, pear];
%let variations=[red &fruits big &quant,red &fruits &quant, blue &fruit &quant, blue &fruits &quant ]; ( and so on... there are many variations, the most imp
data have;
mytext ="somedays I'll collect red apples quantity5 and blue pear quantity3 and will eat them " ;
run;the output is extracting the quantity based on the template variations, in the case of data have:
RA = quantity5 ( for 'red apples quantity 5)
BP = quantity3 ( for 'blue pear quantity 3)
the standard search function is below, anyone knows how to perform a search with sas code ( not regex) with hprovided templates ?
if index(mytext,"red apples quantity 5")^=0 then RA=quantity5Thanks.
Why do you exclude regex?
After a quick look at your problem, i can't see any better way to solve this, than by using regex.
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.