Hi,
The book on SAS said that when only some of the values of the BY variable match, a PROC SQL full join will produce the same result as a DATA step match-merge. Here is the example from the book:
data THREE;
input X A $;
datalines;
X A
1 a1
1 a2
2 b1
2 b2
4 d
data FOUR:
input X B $;
datalines;
X B
2 x1
2 x2
3 y
5 v
data merged;
merge three four;
by x;
run;
RESULT from Data step Merge:
X A B
1 a1
1 a2
2 b1 x1
2 b2 x2
3 y
4 d
5 v
proc sql;
select coalesce(three.x, four.x) as X, a, b
from three full join four
on three.x = four.x;
quit;
RESULT from proc sql join:
X A B
1 a2
1 a1
2 b1 x1
2 b1 x2
2 b2 x1
2 b2 x2
3 y
4 d
5 v
Clearly, the proc sql has 2 more rows than the data step merge. Is there something wrong with the code in the proc sql or the book itself was misleading by saying that the proc sql would produce the same result?
Thanks