Date: Tue, 2 Aug 2005 20:47:56 -0400
Reply-To: Ashok <agunuganti@gmail.com>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ashok <agunuganti@GMAIL.COM>
Subject: Re: Summing data by ID
In-Reply-To: <1123028383.884684.11490@g14g2000cwa.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
wardnine,
i guess this is what you want,
data test;
input
ID Salary Expenses Allowance Sales;
datalines;
345 3454 4344 65 2
915 5465 65 3 3
216 6574 210 81 4
502 1125 105 23 7
915 7256 105 12 4
915 7582 23 94 6
345 2274 4 7 11
261 3105 1123 17 13
502 2756 905 11 7
run;
proc sql;
create table test_summary as
select id,sum(salary),sum(Expenses),sum(Allowance),sum(Sales)
from test
group by id;
quit;
cheers
Ashok
On 8/2/05, wardnine@hotmail.com <wardnine@hotmail.com> wrote:
>
> Hello! I have a SAS data set where the first column contains a three
> digit ID number. I have hundreds of rows with ID numbers and many of
> the ID numbers appear multiple times. Below is a partial example:
>
> ID Salary Expenses Allowance #Sales
>
> 345 3454 4344 65 2
> 915 5465 65 3 3
> 216 6574 210 81 4
> 502 1125 105 23 7
> 915 7256 105 12 4
> 915 7582 23 94 6
> 345 2274 4 7 11
> 261 3105 1123 17 13
> 502 2756 905 11 7
>
> Again, in my file I have hundreds of IDs, many occuring more than once
> and there are roughly 100 observations for each of the IDs (a lot more
> than the 4 - Salary, Expenses, Allowance, and #Sales - shown
> above).What I wanted to do was write SAS code to create a new dataset
> that sums the data for each unique ID. For the example above, I'd want
> the salary, expenses, allowance, #sales, etc. data summed for all 3
> occurences of id 915, both occurences of id 502, and both occurences of
> id 345 and placed in a new dataset sorted by ID. If anyone knows how to
> go about doing this that would be appreciated... thanks!!!
>
> Julie
>
|