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