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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.