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.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.