Hello,
I'm wondering if there is a way to concatenate multiple databases together without having to write them all. I have a lot of databases that are the same but with information on the last ten years.
INFO_2021
INFO_2020
INFO_2019
...
INFO_2012
And I want to put them all together in one database, one year after the other. Here is what I did:
DATA INFO_TOT;
SET INFO_2012 INFO_2013 INFO_2014 INFO_2015 INFO_2016 INFO_2017 INFO_2018 INFO_2019 INFO_2020 INFO_2021;
RUN;
I was wondering if there is a more efficient way maybe with a loop? Something that I could do
DATA INFO_TOT;
SET INFO_2012 TO INFO_2021;
RUN;
Here is an sample data an coding example.
Data info_2012;
a=1;
output;
a=2;
output;
run;
Data info_2013;
a=3;
output;
a=4;
output;
run;
Data info_2014;
a=5;
output;
a=6;
output;
run;
DATA INFO_TOT;
SET INFO_2012-INFO_2014 ;
RUN;
Here is an sample data an coding example.
Data info_2012;
a=1;
output;
a=2;
output;
run;
Data info_2013;
a=3;
output;
a=4;
output;
run;
Data info_2014;
a=5;
output;
a=6;
output;
run;
DATA INFO_TOT;
SET INFO_2012-INFO_2014 ;
RUN;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.