Hi,
The automatic IN variable is a retained variable so that if dataset A has two records
and dataset B has one record for a by group then the non-by variable values in dataset B and the dataset B IN variable are retained. To see if a dataset is contributing a new physical record, not a retained record do the following.
data x;
ina=0;
inb=0;
merge a(in=ina) b(in=inb);
by x;
By setting the retain IN varibale to 0 before the merge statment, it forces SAS to reset it to 1 if a new physical record is read, otherwise it will be 0.
You can have this functionality and the default at the same time by doing the following:
data x;
retain inaX inbX 0;
ina=0;
inb=0;
merge a(in=ina) b(in=inb);
by x;
if first.x then
do;
inaX=ina;
inabX=inb;
end;
This way inaX and inbX behave with the default functionality and you have the new functionality of ina and inb.
... View more