To focus on one part of your question, the WHERE statement does not use calculated fields. With exceedingly rare exceptions, it only references fields that already exist in the SAS data set. I'm not sure if this will confuse matters or suggest greater insight, but here's a test program you can run:
data test1;
do k=1 to 20;
output;
end;
run;
data test2;
set test1;
k=50;
where k < 5;
run;
You will get the 4 observations that have K < 5, before any calculations have been applied. But the final value of K will be 50, after the calculations have been applied.