|
Ya,
Man, you must be pulling our sas-leg:
%let factor = 1000 ;
data squeezed ( keep = id max_dos max_cnt ) ;
array grp ( 0 : &factor ) _temporary_ ;
do _n_ = lbound (grp) to hbound (grp) ;
grp (_n_) = . ;
end ;
do until ( last.id ) ;
set xx ;
by id ;
grp (dos * &factor) ++ 1 ;
end ;
do _n_ = hbound (grp) by -1 until ( grp(_n_) ) ;
end ;
max_dos = _n_ / &factor ;
max_cnt = grp(_n_) ;
run ;
Kind regards,
---------------------------------
Paul M. Dorfman
Jacksonville, FL
---------------------------------
>From: "Huang, Ya" <yhuang@AMYLIN.COM>
>Reply-To: "Huang, Ya" <yhuang@AMYLIN.COM>
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: One pass to find max and maxcnt using data step?
>Date: Wed, 4 Jun 2003 15:47:00 -0700
>
>Hi there,
>
>data xx;
>input id dos;
>cards;
>1 0.1
>1 0.1
>1 0.01
>1 0.01
>1 0.01
>1 0.01
>1 0.3
>1 0.3
>1 0.3
>2 0.2
>2 0.2
>2 0.6
>2 0.05
>2 0.05
>2 0.05
>2 0.05
>2 0.6
>2 0.6
>2 0.6
>2 0.6
>2 0.6
>;
>
>For the above data, I need to find, for each id, the max of dos,
>and the number of dos at the max level, so the expected result
>is as below:
>
>id max_dos maxcnt
>1 0.3 3
>2 0.6 6
>
>It is very easy to get the max_dos, I just wonder if it is
>possible to get the count of max_dos in the same step?
>
>Any comments?
>
>Thanks
>
>Ya
_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
|