I have
data A;
input id caldt ret;
datalines;
1 01-2019 9
1 02-2019 10
2 03-2018 2
2 04-2018 4;
data B;
input id caldt tna;
dataline;
1 01-2020 12
1 02-2021 11
2 03-2019 3
2 04-2019 2;
want
id tna ret
1 12 9
1 11 10
2 3 2
2 2 4
Here's the simplest program that might work:
data want;
set A;
set B;
keep id tna ret;
run;
If you were to actually describe your intentions, a better program might be possible. This program just matches observation by observation: first from A with first from B, second from A with second from B, third from A with third from B, etc. Perhaps that is what you want, but if not you will have to do more of the work.
What have you tried? SQL or Data step?
If you're not familiar with merges at all, the documentation has a full set of examples here (with code and data examples):
You want to look at one to one merging or match merging section.
@sasphd wrote:
I have
data A;
input id caldt ret;
datalines;
1 01-2019 9
1 02-2019 10
2 03-2018 2
2 04-2018 4;
data B;
input id caldt tna;
dataline;
1 01-2020 12
1 02-2021 11
2 03-2019 3
2 04-2019 2;
want
id tna ret
1 12 9
1 11 10
2 3 2
2 2 4
sql
Here's the simplest program that might work:
data want;
set A;
set B;
keep id tna ret;
run;
If you were to actually describe your intentions, a better program might be possible. This program just matches observation by observation: first from A with first from B, second from A with second from B, third from A with third from B, etc. Perhaps that is what you want, but if not you will have to do more of the work.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.