Hi,
I have 100 large datasets (a,b,c,d,e...) and 50 variables that I need to exclude from those datasets in a set statement.
How can I set up a Macro to efficiently exclude these from each dataset before creating the final dataset 'want'?
variables to exclude:
d1, d2, d3, f1, f4, g7, h9...etc
data want;
set
a
b
c
d
e
...
run;
No macro needed
data want;
set a b c d e ... ;
drop d1 d2 d3 f1 f4 ...;
run;
or if you really want to improve the efficiency of the execution time (Again no macro needed but a macro variable ... which is not a macro ... is used)
%let excl = (drop=d1 d3 d3 f1 f4 ...);
data want;
set a&excl b&excl c&excl ...
run;
No macro needed
data want;
set a b c d e ... ;
drop d1 d2 d3 f1 f4 ...;
run;
or if you really want to improve the efficiency of the execution time (Again no macro needed but a macro variable ... which is not a macro ... is used)
%let excl = (drop=d1 d3 d3 f1 f4 ...);
data want;
set a&excl b&excl c&excl ...
run;
Thanks PaigeMiller. The variables need to be dropped within the set statement as they are causing issues when trying to set together. Your second macro code is what I was after.
@PetePatel wrote:
Thanks PaigeMiller. The variables need to be dropped within the set statement as they are causing issues when trying to set together. Your second macro code is what I was after.
Great. But there are no macros here. There is a macro variable, which is not a macro.
@PetePatel wrote:
Thanks PaigeMiller. The variables need to be dropped within the set statement as they are causing issues when trying to set together. Your second macro code is what I was after.
If the particular issue(s) were mismatched variable types or lengths of character variables it may be time to address how the data sets are created.
If the issue was just data set size that's another story.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.