Hello Everyone,
Is there any way to shorten the below code since all "have" files are from the same lib?
Thank you,
HHCFX
data want; set libname.have1 libname.have2 libname.have3 libname.have4;run;
Then there's no way to reduce the set statement. Unless you have some criteria that helps you in selecting your datasets from dictionary.tables and putting all dataset names (including the library) into a macro variable.
Then there's no way to reduce the set statement. Unless you have some criteria that helps you in selecting your datasets from dictionary.tables and putting all dataset names (including the library) into a macro variable.
Thanks for your info.
I hope it could be something like libname.( list of datasets...);
Yes, this should be achieved, because you already have the data sets which are in numbered range lists. You can try below:
data want; set libname.have1-libname.have4; run;
Hi @hhchenfx Try to read the dataset names from dictionary tables and create a list macrovar. Then call the macrovar in your set statement. This can help you avoid typing
Following up on @novinosrin suggestion:
%let myLib=WORK;
proc sql noprint;
select catx(".", "&myLib", memname) into :name_list separated by " "
from sashelp.vtable
where libname=upcase("&myLib.");
quit;
data want;
set &name_list;
run;
This approach works if you have less than 1500+ variables due to the length restrictions of a SAS macro variable.
@hhchenfx wrote:
Hello Everyone,
Is there any way to shorten the below code since all "have" files are from the same lib?
Thank you,
HHCFX
data want; set libname.have1 libname.have2 libname.have3 libname.have4;run;
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.