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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1847 views
  • 0 likes
  • 3 in conversation