Date: Tue, 2 Aug 2005 22:14:11 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: Summing data by ID
Assuming that ID is a character variable, try:
proc summary data=have nway;
class id;
var _numeric_;
output out=want(drop = _type_ _freq_) sum=;
run;
On Tue, 2 Aug 2005 17:19:43 -0700, 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
|