Date: Wed, 5 Sep 2007 12:00:03 -0400
Reply-To: Jack Clark <JClark@CHPDM.UMBC.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Clark <JClark@CHPDM.UMBC.EDU>
Subject: Re: SAS coding help
In-Reply-To: A<456207.45467.qm@web33306.mail.mud.yahoo.com>
Content-Type: text/plain; charset="us-ascii"
Cherub,
You could use counter logic to increment rank, and use first. logic to
reset the counter each time a new ID value is reached.
Data need;
Set have;
By id date;
If first.id then rankvar = 0;
rankvar + 1;
Run;
Jack Clark
Research Analyst
Center for Health Program Development and Management
University of Maryland, Baltimore County
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
cherub
Sent: Wednesday, September 05, 2007 11:48 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: SAS coding help
Hi,
I need some help for my coding. Now I have a dataset sorted by date
and id(see below)
Id date key
12 12May2001 1254
12 13Dec2004 1204
12 15Jan2005 1002
15 15Apr1998 0998
15 05Feb2000 0147
......
I need to generate a new variable which can give the rank for date by
id, such as
Id date Key rank
12 12May2001 1254 1
12 13Dec2004 1204 2
12 15Jan2005 1002 3
15 15Apr1998 0998 1
15 05Feb2000 0147 2
......
Does somebody know how to generate this variable?
Thanks
Yanyan
---------------------------------
Looking for a deal? Find great prices on flights and hotels with Yahoo!
FareChase.