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 an old and a new data set that looks like this

old data set

id   group  characteristics

1    age      2 years old

2    age      5 years old

 

new data set

id   group  characteristics

3    age      3 Years old

4    age      5 Years old

 

I want to combine these two. However, as you can see, the old data set has "years" and the new data set has "Years"

 

How can I change the characteristics in my new data set so they are all lower case? Is there a simple way other than writing the same line for every characteristic? e.g., 

if characteristics eq "3 Years old" then characteristics = "3 years old"

if characteristics eq "5 Years old" then characteristics = "5 years old"

 

Is there a simple way to do this all at once?

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

data want;

   set have;

   characteristics = lowcase(characteristics);

run;

 

There are three basic character case functions in SAS: Lowcase, make all characters lower case, Upcase, make all characters upper case and Propcase, makes first letter of each "word" upper case and others lower case.

 

There are additional functions KLowcase, Kupcase and Kpropcase that do the same things for double-byte character sets.

 

 

View solution in original post

4 REPLIES 4
maguiremq
SAS Super FREQ
data want;
set have;
new_var = lowcase(original_var);
run;

You can call it on your original variable, but it's probably a good idea to just create a new one.

geneshackman
Pyrite | Level 9
Thanks, this worked!
ballardw
Super User

data want;

   set have;

   characteristics = lowcase(characteristics);

run;

 

There are three basic character case functions in SAS: Lowcase, make all characters lower case, Upcase, make all characters upper case and Propcase, makes first letter of each "word" upper case and others lower case.

 

There are additional functions KLowcase, Kupcase and Kpropcase that do the same things for double-byte character sets.

 

 

geneshackman
Pyrite | Level 9
Hi Ballarddw, this worked!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1171 views
  • 2 likes
  • 3 in conversation