Date: Wed, 5 Sep 2007 10:05:17 -0700
Reply-To: Syb it <sas_datalover@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Syb it <sas_datalover@YAHOO.COM>
Subject: Re: SAS coding help
In-Reply-To: <456207.45467.qm@web33306.mail.mud.yahoo.com>
Content-Type: text/plain; charset=iso-8859-1
I would do it like this:
data have;
input Id date date9. key; format date date9.;
datalines;
12 12May2001 1254
12 13Dec2004 1204
12 15Jan2005 1002
15 15Apr1998 0998
15 05Feb2000 0147
;;;
run;
data want;
set have; by Id;
if first.id then do;
rank =0;
end;
rank +1;
output;
run;
cherub <cherub2life@YAHOO.COM> wrote:
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.
---------------------------------
Need a vacation? Get great deals to amazing places on Yahoo! Travel.