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

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.

1 ACCEPTED SOLUTION
3 REPLIES 3
Reeza
Super User

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. 

ballardw
Super User

@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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 962 views
  • 3 likes
  • 4 in conversation