Why does the result of the following two alternative ways of stacking two datasets differ?
data work.a;
length ds $1;
ds = 'A';
do i = 1 to 3;
output;
end;
run;
data work.b;
length ds $1;
ds = 'B';
do i = 1 to 3;
do j = 1 to 3;
output;
end;
end;
run;
*- ALTERNATIVE 1 -*;
data work.c;
set work.a work.b;
if j = . then j = i;
run;
*- ALTERNATIVE 2 -*;
data work.d;
set work.a work.b;
run;
data work.d;
set work.d;
if j = . then j = i;
run;
My guess would be that both dataset c and d have j = i where ds = 'A'.