@Bhargav_Movva wrote:
Can't we use datastep merge statement to accomplish the same..??
Of course you can. But then you have to rename the variables of one dataset, so you can then use the coalesce function on the originally named variables from dataset A and the renamed variables from B. The data step does not have the a. and b. notation for variables that SQL has, and without a rename the values would simply overwrite in a not very predictable manner.
Assume that the c1-c33 notation is in effect and the datasets are sorted by id:
%macro merge_it;
data C;
merge
a
b (rename=(
%do i = 1 %to 33;
c&i.=_c&i.
%end;
))
;
by id;
%do i = 1 %to 33;
c&i. = coalesce(c&i.,_c&i.);
drop _c&i.;
%end;
run;
%mend;
%merge_it
A similar macro for the proc SQL would be simpler to write. Which way you go could be determined by performance in case of large datasets (SQL can be quite bad there).
... View more