Hello,
I have a dataset "nh.weekday1" that contains many variables starting with "dr1" such as "dr1drs" and "dr1_tak", I want to rename those variables starting with "wkdy", so they become "wkdydrs" and "wkdy_tak". My code and log are below. Could you please tell me what went wrong and how to fix it?
Thank you!
proc sql noprint;
select cats(name,"=",tranwrd(name,"dr1","wkdy")) into :renames separated by " "
from dictionary.columns
where libname="NH"
and memname="weekday1"
and name like "dr1";
quit;
proc datasets library=nh nolist;
modify weekday1;
rename &renames;
quit;
Hello @knighsson,
In addition to the wrong case of "weekday1" you missed the wildcard character (%) in the LIKE condition:
and name like "dr1%"
which could also be written as
and name eqt "dr1"
(analogous for upcase(name), if needed).
Keep in mind that memname, like libname, is uppercase in the DICTIONARY tables. For most values in name, this will also be true, so you should convert it with UPCASE and compare with "DR1".
Thank you for your help! however, it is still not working.
Your SQL log says "NOTE: No rows selected". So your WHERE clause is not finding any hits in the table.
Most likely you don't have the proper capitalization. MEMNAME and NAME should be all capital letters.
Hello @knighsson,
In addition to the wrong case of "weekday1" you missed the wildcard character (%) in the LIKE condition:
and name like "dr1%"
which could also be written as
and name eqt "dr1"
(analogous for upcase(name), if needed).
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.