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

Hi! I'm trying to rename some observations in my school_name variable. Currently, the school names look like this:

turnc.PNG

 

I want to rename them to look like this: 

Capture.PNG

In the data step, my code looks like this: 

length school_name $ 30;
	
if school_name = "Washington Elem" then School_Name = "Washington Elementary School";
if school_name = "Lin coln School" then School_Name = "Lincoln Elementary School";
if school_name = "Adams Elem" then School_Name = "Adams Elementary School";
if school_name = "Jackson" then School_Name = "Jackson Elementary School";

However, after renaming, it looks like this: 

Capture.PNG

 

Why do they get truncated? I added that line 

length school_name $ 30;

in the hopes of the names not being truncated, but it didn't change anything.

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

try 

length school_name $ 30;

before set statement 

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

try 

length school_name $ 30;

before set statement 

novinosrin
Tourmaline | Level 20
data have;
input school_name= $16. ;
school_name=dequote(school_name);
cards;
school_name = "Washington Elem"
school_name = "Lin coln School"
school_name = "Adams Elem" 
school_name = "Jackson"
;
data want;
length school_name $ 30;
set have;
if school_name = "Washington Elem" then School_Name = "Washington Elementary School";
if school_name = "Lin coln School" then School_Name = "Lincoln Elementary School";
if school_name = "Adams Elem" then School_Name = "Adams Elementary School";
if school_name = "Jackson" then School_Name = "Jackson Elementary School";
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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