DATA Step, Macro, Functions and more

Substring search

Accepted Solution Solved
Reply
Contributor
Posts: 42
Accepted Solution

Substring search

Dear all,

 

I need to go through a column and do substring search and only inlude the entry containing "within 10 minutes", "within 15 minutes", "minutes" "within" and "infusion", is this doable in SAS?

 

Thank you

zimcom 


Accepted Solutions
Solution
a month ago
Respected Advisor
Posts: 3,258

Re: Substring search

[ Edited ]

Yes, SAS can do this. Something like this, where text is the variable in your data set that you want to search.

 

Data want;
    set have;
    if find(text,'within 10 minutes')>0 or find(text,'infusion')>0 or ... 
         /* you type the rest */ then output;
run;

Also, did you really mean to use the word "and"? The code I gave assumes you really meant "or". 

--
Paige Miller

View solution in original post


All Replies
Solution
a month ago
Respected Advisor
Posts: 3,258

Re: Substring search

[ Edited ]

Yes, SAS can do this. Something like this, where text is the variable in your data set that you want to search.

 

Data want;
    set have;
    if find(text,'within 10 minutes')>0 or find(text,'infusion')>0 or ... 
         /* you type the rest */ then output;
run;

Also, did you really mean to use the word "and"? The code I gave assumes you really meant "or". 

--
Paige Miller
Contributor
Posts: 42

Re: Substring search

Posted in reply to PaigeMiller

Love SAS Communities!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 65 views
  • 1 like
  • 2 in conversation