Hi all,
I have some repeated longitudinal data and I want to merge them by ID. I'm trying to add the additional data as extra rows for that ID.
Data1
ID
|
Date
|
Age
|
12345
|
01DEC2020
|
25
|
12345
|
02MAR2021
|
26
|
12345
|
03APR2022
|
27
|
Data2
ID
|
Date
|
Age
|
Data_Out
|
XYZ_Out
|
12345
|
01DEC2027
|
32
|
YES
|
0.21
|
12345
|
02MAR2028
|
33
|
NO
|
0.99
|
12345
|
03APR2029
|
34
|
YES
|
0.64
|
12345
|
04AUG2030
|
35
|
.
|
0.85
|
12345
|
05DEC2031
|
36
|
YES
|
0.19
|
What I'd like to create is the table below where rows from Data2 is added on top of Data1 (so that they're in chronological order based on date and age):
ID
|
Date
|
Age
|
Data_Out
|
XYZ_Out
|
12345
|
01DEC2020
|
25
|
|
|
12345
|
02MAR2021
|
26
|
|
|
12345
|
03APR2022
|
27
|
|
|
12345
|
01DEC2027
|
32
|
YES
|
0.21
|
12345
|
02MAR2028
|
33
|
NO
|
0.99
|
12345
|
03APR2029
|
34
|
YES
|
0.64
|
12345
|
04AUG2030
|
35
|
.
|
.
|
12345
|
05DEC2031
|
36
|
YES
|
0.19
|
The code I have right now is not merging the way I'd like as it ends up merging horizontally and duplicates the row data. It also gives me a "WARNING: Multiple lengths were specified for the BY variable Subject by input data sets" error.
data want;
merge data1 (in=A) data2 (in=B);
by ID;
if A;
run;
Any help with this would be appreciated, thanks.