Finding Max Observation By Data Step Only In SAS

Hi All,

Suppose we have a data set like below:

EmpID      EmpSal     EmpName

E001          5000          A

E002          7500          B

E003          2500          C

E004          9800          D

E005          6100          E

 

I am looking for the maximum salaried EmpID / EmpName or whatever which should contain maximum value from a variable.

then you can try like it, without using any procedures and options:

 

data want;

   set have nobs=_nobs_;

   if EmpSal > max_EmpSal then do;

     max_EmpSal = EmpSal;

     max_EmpID = EmpID;

     max_EmpName = EmpName;

   end;

   retain max_:;

   keep max_:;

   if _n_ = _nobs_;

run;

 

No comments:

Post a Comment