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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 743 views
  • 3 likes
  • 4 in conversation