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;
The 2025 SAS Hackathon Kicks Off on June 11!
Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.