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

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