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=quantity5
Thanks.
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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.