Hi all,
I have an error and I don't know how to fix it. The problem occurs at the RENAME option in my macro. What is weird is that if I copy the MPRINT statement in the log (see below in Bold) and run it in SAS, I don't have an error and the dataset is created?
Here's the code:
You are out-complicating yourself. I take it you run a SQL select from dictionary.columns to get your variable names. You can do everything much easier by using call execute off sashelp.vcolumn in a data _null_ step:
data _null_;
set sashelp.vcolumn (where=(libname = "&lib." and memname = "&data." and /* insert your condition(s) here */)) end=eof;
if _n_ = 1 then call execute("proc datasets library=&lib.; modify &data.; rename");
call execute(cats(' ',name,'=',"&prefix.",name));
if eof then call execute(";quit;");
run;
PS I do not think the %bquote is necessary.
You are out-complicating yourself. I take it you run a SQL select from dictionary.columns to get your variable names. You can do everything much easier by using call execute off sashelp.vcolumn in a data _null_ step:
data _null_;
set sashelp.vcolumn (where=(libname = "&lib." and memname = "&data." and /* insert your condition(s) here */)) end=eof;
if _n_ = 1 then call execute("proc datasets library=&lib.; modify &data.; rename");
call execute(cats(' ',name,'=',"&prefix.",name));
if eof then call execute(";quit;");
run;
PS I do not think the %bquote is necessary.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.