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

Hi experts,

 

I have a challenge situation here.   I would like to looking for a text with 'Health Center' in one of my variables.   However, it comes with different formats and different places.   I am curious, if there is a way to find them.  Thanks!

 

For example,

1. Health Center

2. health center

3. Health center

4. Health State Center

5. State health center

6. Health Department Center

7. Department health center

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

I would assume you wanna match text that basically should have both words. 

 

How about 

 

 

where findw(test,'health',' ','i') and findw(test,'center',' ','i');

/*or making sure health precedes center*/

where findw(test,'center',' ','i')>findw(test,'health',' ','i');

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

Do you mean this?

 

data have;
input test $40.;
cards;
1. Health Center
2. health center
3. Health center
4. Health State Center
5. State health center
6. Health Department Center
7. Department health center
;

data want;
set have;
where findw(test,'health center',' ','i');
run;

 

ybz12003
Rhodochrosite | Level 12

No, I would like to find all the seven answers even though there are one word in-between 'Health Center' or in front of it. 

novinosrin
Tourmaline | Level 20

I would assume you wanna match text that basically should have both words. 

 

How about 

 

 

where findw(test,'health',' ','i') and findw(test,'center',' ','i');

/*or making sure health precedes center*/

where findw(test,'center',' ','i')>findw(test,'health',' ','i');
ybz12003
Rhodochrosite | Level 12

Thanks, that's what I want!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 799 views
  • 1 like
  • 2 in conversation