Hi! I'm trying to rename some observations in my school_name variable. Currently, the school names look like this:
I want to rename them to look like this:
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:
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.
try
length school_name $ 30;
before set statement
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.