BookmarkSubscribeRSS Feed
annaba
Calcite | Level 5

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 : 

79 proc datasets library = mine nolist;
80 modify petitVEST2;
WARNING: Apparent symbolic reference RENAME_LIST not resolved.
81 rename &rename_list.;
_
22
76
NOTE: Enter RUN; to continue or QUIT; to end the procedure.
ERROR 22-322: Expecting un nom.
ERROR 76-322: Syntax error, statement will be ignored.
 
Please help me!
 
Anna
1 REPLY 1
Tom
Super User Tom
Super User

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))

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 1 reply
  • 1076 views
  • 0 likes
  • 2 in conversation