[prev in list] [next in list] [prev in thread] [next in thread]
List: sas-l
Subject: Re: aggregating a single numeric field by an ID#
From: Paul Kairis <kairis () HOME ! COM>
Date: 1998-09-30 15:55:41
[Download RAW message or body]
Pamela Mery wrote:
> like to total the attendance hours for each student for all of the classes
> that student enrolled in. In the example below three ID numbers are
> represented. If totalled, each of their hours would equal fifteen. >
> ID HOURS
> 14890 8
> 14890 2
> 14890 5
> 28954 12
> 28954 3
> 88965 15
> etc.
That should do it ...
data a;
infile cards;
input ID $6. hr;
cards;
14890 8
14890 2
14890 5
28954 12
28954 3
88965 15
;
proc sort data = a; by ID;
run;
;
data b( drop = hr );
set a; by ID;
if first.ID then sum = 0;
sum + hr;
if last.ID then output;
run;
proc print data = b;run;
Paul Kairis
SAS Quality Partner
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic