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

I have a data set that has a variable, "Group". Some cases have the value "Urban-Rural Residence". Some other cases have a value that is almost the same, but for some reason not exactly the same, although I don't see how. Excel thinks the other value is exactly the same. 

 

I doubt it would be worth it to post or send a data set, because I'm not sure if any data set i post or send would actually have the difference in values.

 

Instead, I would like have code that says the following, and my question is how to do it.

 

If the value includes the string "Urban" then Group = "Urban-Rural Residence";

 

Thus, i would find some part of the value that hopefully is identical in all versions of the value, and just manually make them all have the same value. 

 

There seem to be a bunch of sas functions that might do this, but I don't quite get the difference in them all, even though I've searched a bit and read a bunch of stuff. What's the difference between contain, find, findw, index? Or would I use some other function?

 

Thanks

 

Gene

 

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Try:  

group = compress(group,,'kA');

or

if index(group,'Urban') then group = "Urban-Rural Residence";

 

View solution in original post

2 REPLIES 2
Shmuel
Garnet | Level 18

Try:  

group = compress(group,,'kA');

or

if index(group,'Urban') then group = "Urban-Rural Residence";

 

geneshackman
Pyrite | Level 9
Thanks very much. This one worked.
if index(group,'Urban') then group = "Urban-Rural Residence";

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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