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:
ID | Item |
12345B | Tennis Shoes |
2325hg | Socks |
SD4587 | XYZ Shoe |
D235F | Other |
I need the new data to look like this (please note the third observation is shoe and not shoes):
ID | Item | Shoes |
12345B | Tennis Shoes | Yes |
2325hg | Socks | No |
SD4587 | XYZ Shoe | Yes |
D235F | Other | No |
Many thanks
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?
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';
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?
Right. I just needed a lead for this issue. It is much more than that.
Many thanks though
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.