Date: Thu, 9 Oct 2003 08:49:13 +0800
Reply-To: Zibao Zhang <zibaozhang@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Zibao Zhang <zibaozhang@HOTMAIL.COM>
Subject: Re: Setting a Counter
Content-Type: text/plain; charset="iso-8859-1"
Hi Bob,
the LAG fuction in data step would work. here is a tested code below. Hope this helps,
data a;
input Name $ 1-10;
datalines;
J Jones
J Jones
J Jones
A Adams
S Smith
S Smith
D Doe
D Doe
D Doe
D Doe
D Doe
run;
data b;
set a;
if name ne lag(name) then count+1;
run;
proc report data=b nowd;
column count name;
define count /group;
run;
============
Kind Regards,
Zibao Zhang, MD
----- Original Message -----
From: "Baxley, Robert Edwin" <BAXLEYR@MAIL.ETSU.EDU>
Newsgroups: bit.listserv.sas-l
To: <SAS-L@LISTSERV.UGA.EDU>
Sent: Thursday, October 09, 2003 4:33 AM
Subject: Setting a Counter
SAS-L,
I've got a data set with multiple records per individual. It looks (partially) like this:
Name
J Jones
J Jones
J Jones
A Adams
S Smith
S Smith
D Doe
D Doe
D Doe
D Doe
D Doe
I want to keep all of the multiple records and assign a number to individuals so it looks like this:
Counter Name
1 J Jones
J Jones
J Jones
2 A Adams
3 S Smith
S Smith
4 D Doe
D Doe
D Doe
D Doe
D Doe
Can someone help me with an easy way to accomplish this? Or at least send me in the right direction and
I'll research it from there. Please bear in mind that even though I've used SAS for many years, I'm not adept.
I know nothing of SQL or Macros (or Marcos, for that matter <g>).
Thanks!
Bob