I have the following SAS code in a macro. I have i=1 to 34 and j=1 to 3 data sets that I am setting to Xall_final&i._&j. I want to drop all data sets xafin&i._1, xbfin&i._1, and xcfin&i._1. That is all data sets in which j=1. I don't get an error but get this in the log.
WARNING: The variable xafin34_1 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable xbfin34_1 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable xcfin34_1 in the DROP, KEEP, or RENAME list has never been referenced.
Can someone tell me why I get this message and how should I properly reference the data sets xafin&i_1 that I want to drop?
data Xall_final&i._&j;
set Xafin&i._&j Xbfin&i._&j Xcfin&i._&j;
drop xafin&i._1 xbfin&i._1 xcfin&i._1;
/*drop subn2-subn34;
drop sub1 subj2-subj34;*/
*Label an1='Param';
run;
You drop variables not data sets. Drop the drop statement that names data sets.
You drop variables not data sets. Drop the drop statement that names data sets.
As pointed out it was a mistake on my part to try and drop a data set. The issue was resolved by having the original macro to start at 2 instead of 1:
(%macro bootr;
%do i=1% to 34;
%do j=2% to 10;)
@jacksonan123 wrote:
I have the following SAS code in a macro. I have i=1 to 34 and j=1 to 3 data sets that I am setting to Xall_final&i._&j. I want to drop all data sets xafin&i._1, xbfin&i._1, and xcfin&i._1. That is all data sets in which j=1. I don't get an error but get this in the log.
WARNING: The variable xafin34_1 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable xbfin34_1 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable xcfin34_1 in the DROP, KEEP, or RENAME list has never been referenced.
Can someone tell me why I get this message and how should I properly reference the data sets xafin&i_1 that I want to drop?
data Xall_final&i._&j; set Xafin&i._&j Xbfin&i._&j Xcfin&i._&j; drop xafin&i._1 xbfin&i._1 xcfin&i._1; /*drop subn2-subn34; drop sub1 subj2-subj34;*/ *Label an1='Param'; run;
Where is the code that worked to do what you need before starting to write the macro? That should always be the first step.
And since SET combines data sets, what do you mean by "drop" a data set that appears on a SET statement?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.