- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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".
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your help! however, it is still not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you!