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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.