Hello:
I would like to extract the text contain 'NOS' or 'MISC' from column A, D, G and H. 'NOS' and 'MISC' could be either capital or low case. In additional, they could be only part of text. For example, 'Defect-Nos' contains 'NOS'. 'MISCELLANEOUS' or 'MISC.' contain 'MISC'. I would like to find all of the possibility. In other words, the result should includes 'Defect-Nos', 'MISCELLANEOUS' and 'MISC.' from all of the four columns. Could someone let me know how to approach it? Thanks.
To find a string within an other string, use the index() or find() functions.
Insert the words you're looking for into a temporary array and loop through your list. Look at the third parameters of the INDEX and FIND functions so they ignore case.
To find a string within an other string, use the index() or find() functions.
@ybz12003 wrote:
Hello:
I would like to extract the text contain 'NOS' or 'MISC' from column A, D, G and H. 'NOS' and 'MISC' could be either capital or low case. In additional, they could be only part of text. For example, 'Defect-Nos' contains 'NOS'. 'MISCELLANEOUS' or 'MISC.' contain 'MISC'. I would like to find all of the possibility. In other words, the result should includes 'Defect-Nos', 'MISCELLANEOUS' and 'MISC.' from all of the four columns. Could someone let me know how to approach it? Thanks.
You might want to consider the difference in the statement if change the highlighted all to any.
'All' would usually be used when you require the condition to be true for each and every column of interest. Which in much computer syntax means comparisons joined with "and". Any would be at least one of the is true so a computer syntax "or" would appear between comparisons.
Since you have multiple columns to search you might consider providing some example input and show the desired result.
The result is important as you could well have 4 "text containing". Should the result be in a single variable? four variables? If multiple variables is order important?
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.