Hi all, I'm trying to merging two data sets based on some field in common and different observations. I have something like that: TABLE 1 TABLE 2 id date KPI_1 KPI_2 x id date KPI_1 KPI_2 A 01JAN17 10 23 GREEN A 01JAN17 1 3 B 01-feb-17 12 3 RED B 01-mar-17 1 5 C 01-mar-17 14 56 BMW F 01JUN17 5 6 D 01-apr-17 15 67 OK I want a third table with all obs from TABLE_1 and all obs from TABLE_2 (if id + date are not in TABLE_1). Below the wanted output: id date KPI_1 KPI_2 x A 01JAN17 10 23 GREEN B 01-feb-17 12 3 RED C 01-mar-17 14 56 BMW D 01-apr-17 15 67 OK B 01-mar-17 1 5 F 01JUN17 5 6 I wrote the below code, but i'm missing something: data dataa;
length id $1 date $7 KPI_1 $6 KPI_2 $6 x $6;
infile datalines dlm=",";
input id date KPI_1 KPI_2 x;
datalines;
A,01JAN17,10,23,GREEN
B,01FEB17,12,3,RED
C,01MAR17,14,56,BMW
D,01APR17,15,67,OK
;
run;
data datab;
length id $1 date $7 KPI_1 $6 KPI_2 $6;
infile datalines dlm=",";
input id date KPI_1 KPI_2;
datalines;
A,01JAN17,1,3
B,01MAR17,1,5
F,01JUN17,5,6
;
run;
data datac;
merge dataa(in=a) datab(in=b);
by id date;
if a or not b;
run; Could anyone help me? Thanks for your assistance.
... View more