Hi,
I'm trying to rename all my variables by cutting the first and the last letters.
I used this code :
data mine.petitVEST2;
set mine.petitTEST1;
run;
proc sql;
select cats(name ||'='|| substr(name,2,4)) into: rename_list separated by " "
from dictionary.columns
where libname="mine" and memname="petitVEST2";
quit;
proc datasets library = mine nolist;
modify petitVEST2;
rename &rename_list;
quit;
proc contents data = mine.petitVEST2;
run;
but I received this error message :
Because your query will never match any variables. The LIBNAME and MEMNAME variables in that view are always in uppercase.
If you want to remove the first and last character you need to know the length.
catx('=',name,substr(name,2,length(name)-2))
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!
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.