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";

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 361 views
  • 1 like
  • 2 in conversation