I'd like to write a code that creates column C from A and B. Column C will be, the value of A from the row where B is the smallest value greater or equal to 0.99. If there are repeated values as in the example, the value must be the first of them.
data want;
_b = 9999999999;
do until (done1);
set have end=done1;
if b > .99 and b < _b
then do;
_c = a;
_b = b;
end;
end;
do until (done2);
set have end=done2;
c = _c;
output;
end;
drop _:;
run;
data have;
input A B;
cards;
1 0.2
2 0.05
3 0.9
4 0.9901
5 0.9901
6 0.9901
7 0.995
;
proc sql noprint;
select a, min(b) into :a trimmed, :b trimmed
from have where b ge 0.99;
quit;
%put a=&a b=&b;
data want;
set have;
c=&a;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Registration is open
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss. Register now and lock in 2025 pricing—just $495!