LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 1996, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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 >


Back to: Top of message | Previous page | Main SAS-L page