| Date: | Thu, 28 Mar 2002 12:08:17 -0500 |
| Reply-To: | Gerhard Hellriegel <ghellrieg@T-ONLINE.DE> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Gerhard Hellriegel <ghellrieg@T-ONLINE.DE> |
| Subject: | Re: DATE |
| Content-Type: | text/plain; charset=ISO-8859-1 |
On Thu, 28 Mar 2002 10:49:45 -0600, Mai To <mto@ADMIN4.HSC.UTH.TMC.EDU>
wrote:
>My dataset has these info:
>
>Emp.ID Name Hire date Termination date
>10000 Smith, A 1996-03-15 1996-12-31
>10000 Smith, A 1997-05-17 1998-05-16
>10000 Smith, A 2000-02-15
>10001 White, M 1996-04-28
>10002 Darcy, R 2000-02-13 2002-01-31
>10002 Darcy, R 1997-06-10 1999-08-31
>
>What I'm trying to do is to find the LATEST hire date, exp. Smith, A
>would have 2000-02-15, Darcy R would have 2000-02-13.
>
>I have the input data as follow:
>
>Data date;
> Infile date;
> Input @ 5 Empid $5.
> @ 20 Name $30.
> @ 55 Hire $10.
> @ 70 Term $10.;
>
>Proc sort data=date;
> By descending Hire;
>
>Data date2; set date;
> By descending Hire;
>
>Proc sort data=date2;
> By Empid;
>
>Data date3; set date2;
> By Empid;
> If first.empid;
>
>It gave me the result I need, but is there a shorter/better way?
>
>Your help is very much appreciated.
>
>Mia
>
What you can do insted is:
1. read the hire date as numeric, e.g. with
input ....
§55 hire : yymmdd10.
..
then use
proc summary data=... nway;
class empid name;
var hire;
output out=x max=;
run;
I'd prefer reading ALL dates as numeric. Also with your method that would
be better.
|