Code: Program data x; infile cards truncover; input ID $ Age1 Age2 Age3 Age4 Age5 Age6 ; cards; A01 10.0 . . . 10.0 11.0 10 A03 . . . 13.1 12.0 13.5 A05 . 12.0 12.0 12.0 12.5 13.0 12 A07 11.8 11.0 11.0 . 13.0 10.0 11 A09 14.0 14.0 10.0 . 10.0 15.0 A11 . . 17.0 . 16.2 17.0 17 A13 11.0 . 11.3 11.0 11.3 11.0 11 A15 . . . 10.7 11.0 10.7 10.7 A17 . 14.0 . 12.1 14.0 12.1 A19 14.0 . . . . . 14 A21 . 12.0 . . . . 12 A23 . . . . 12.0 14.0 A25 12.5 13.0 12.7 13.5 11.9 12.6 ; run; data want(drop=k count i idx max ); if _n_ eq 1 then do; declare hash ha(); declare hiter hi('ha'); ha.definekey('k'); ha.definedata('k','count','idx'); ha.definedone(); declare hash random(ordered:'d'); declare hiter hir('random'); random.definekey('idx'); random.definedata('k','count'); random.definedone(); end; set x; array x{*} age: ; do i=dim(x) to 1 by -1; if not missing(x{i}) then do; k=x{i};idx=i; if ha.find()=0 then do;count+1;ha.replace();end; else do;count=1;ha.add();end; end; end; do while(hi.next()=0); random.add(); end; max=0; do while(hir.next()=0); if count ge max then do;max=count;mod=k;end; end; ha.clear(); random.clear(); run;
... View more