Date: Fri, 19 Aug 2011 22:09:46 -0400
Reply-To: Randy <randistan69@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Randy <randistan69@HOTMAIL.COM>
Subject: Groupings --- Is this correct?
my data set is as follows:
ID
A
A
A
B
B
B
B
B
C
C
What I need is
ID ID_Group
A 1
A 1
A 1
B 2
B 2
B 2
B 2
B 2
C 3
C 3
The code I wrote is as follows:
Data Need ; set Have;
by ID;
If _N_ = 1 then ID_Group = 0 ;
If first.ID then ID_Group +1 ;
run;
|