Date: Wed, 6 Aug 2008 13:49:50 -0700
Reply-To: "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Subject: Re: order/count question
In-Reply-To: A<200808062004.m76HTtBg027296@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
Hi qiantobe -
You want to sort your data, and then put a counter on it using a
datastep. Reset the counter at each by-group.
data a;
input ID $3.;
cards;
001
001
001
002
002
;
run;
proc sort data=a;
by ID;
run;
data a;
set a;
by ID;
if first.ID then UNID=0;
UNID+1;
run;
Paul Choate
DDS Data Extraction
(916) 654-2160
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
SUBSCRIBE SAS-L Anonymous
Sent: Wednesday, August 06, 2008 1:04 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: order/count question
Hi ,
I will be appreciated if you can give me some idea:
How to create new variable UNID which order the records by each ID?
ID UNID
001 1
001 2
001 3
002 1
002 2
Thanks.