BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jacksonan123
Lapis Lazuli | Level 10

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenKuhfeld
Ammonite | Level 13

You drop variables not data sets. Drop the drop statement that names data sets.

View solution in original post

4 REPLIES 4
WarrenKuhfeld
Ammonite | Level 13

You drop variables not data sets. Drop the drop statement that names data sets.

jacksonan123
Lapis Lazuli | Level 10

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;)

 

Reeza
Super User
If you want to drop all you can list or wild card them instead of knowing each index. Or are you trying to selectively drop data sets/variables?
ballardw
Super User

@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?

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 913 views
  • 0 likes
  • 4 in conversation