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;
Ready to join fellow brilliant minds for the SAS Hackathon?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.