BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
altijani
Quartz | Level 8

Greetings Community

 

I have a very simple/quick question:

 

I have a column of the data that contains text. Within that text, I need to look if there is a specific text. My data looks like this:

IDItem
12345BTennis Shoes
2325hgSocks
SD4587XYZ Shoe
D235FOther

 

I need the new data to look like this (please note the third observation is shoe and not shoes):

IDItemShoes
12345BTennis ShoesYes
2325hgSocksNo
SD4587XYZ ShoeYes
D235FOtherNo

 

Many thanks

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Does case matter, i.e. does shoes=Shoes?  If so you might want to upcase.  

if index(upcase(item),"SHOES") then shoes="Yes";

I am sure this isn't your full problem though is it?  Only one word being checked?

View solution in original post

3 REPLIES 3
SuryaKiran
Meteorite | Level 14

use FIND() or INDEX() function if you need to search for a single word. If you have to search for multiple words then use PRXMATCH() function.

 

something like:

 

If FIND(item,'shoe','i')>0 then shoes='YES';else shoes='NO';

 

 

Thanks,
Suryakiran
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Does case matter, i.e. does shoes=Shoes?  If so you might want to upcase.  

if index(upcase(item),"SHOES") then shoes="Yes";

I am sure this isn't your full problem though is it?  Only one word being checked?

altijani
Quartz | Level 8

Right. I just needed a lead for this issue. It is much more than that.

Many thanks though

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1795 views
  • 0 likes
  • 3 in conversation