| Date: | Mon, 15 Apr 1996 10:32:04 -0700 |
| Reply-To: | "ADITYA K. JHA" <jhadas@IX.NETCOM.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU> |
| From: | "ADITYA K. JHA" <jhadas@IX.NETCOM.COM> |
| Subject: | Re: need help on this program |
|---|
The easiest way to set up a counter for observations (I am assuming you
wish to sequentially count each observation within ID) is to use a BY
statement in conjunction with a SET statement and a FIRST.variable
statement.
Like this:
data test;
infile datalines;
input @1 id;
datalines;
AA
AA
BB
BB
BB
CC
DD
DD
DD
DD
;
run;
proc sort;
by id;
run;
data count;
set test;
by id;
if first.id then
counter=1;
else
counter+1;
run;
Hope this helps.
Frank Basile
Ragtime Guitarist
and
Aspiring Computer Geek
You wrote:
>
>I would like to create the counts for each id like this. If any ane
knows
>please
>post the answer or email me.
>
>
>Input:
>
>ID
>----
>AA
>AA
>BB
>BB
>BB
>CC
>DD
>DD
>DD
>DD
>
>
>OUTPUT:
>
>ID CNT
>---- ---
>AA 2
>AA 2
>BB 1
>BB 2
>BB 3
>CC 1
>DD 1
>DD 2
>DD 3
>DD 4
>
|