BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Roxanne1
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
CarmineVerrell
SAS Employee

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;

View solution in original post

2 REPLIES 2
CarmineVerrell
SAS Employee

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 444 views
  • 1 like
  • 2 in conversation