BookmarkSubscribeRSS Feed
SIgnificatif
Quartz | Level 8

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.

1 REPLY 1
andreas_lds
Jade | Level 19

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 363 views
  • 0 likes
  • 2 in conversation