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!

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