```Date: Fri, 17 Dec 2004 16:26:44 -0500 Reply-To: Nathaniel_Wooding@DOM.COM Sender: "SAS(r) Discussion" From: Nat Wooding Subject: Re: Complicated aggregate function? Comments: To: Hjalte Content-type: text/plain; charset=US-ASCII Hjalte This is really not a hard problem. There should be several solutions but here is mine. As you will see, the problem will need to be split into several steps. Nat Wooding data a; input col1-col3; cards; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 data b; * FIRST IDENTIFY THE GROUPS . THE MOD FUNCTION WILL NEED TO BE CHANGED; set a; if _n_=1 then do; group=1; count=0; end; if mod(count,2)=0 then group+1;* THE DIVISOR (2) SHOULD BE 15000 for your work; count+1; proc means noprint; var col:; OUTPUT OUT=B SUM= ; BY GROUP; * AGGREGATE OVER GROUPS; PROC TRANSPOSE OUT=B;* NOW SWAP ROWS AND COLUMNS; VAR COL:; ID GROUP; PROC PRINT; RUN; Hjalte To: SAS-L@LISTSERV.UGA.EDU Sent by: "SAS(r) cc: Discussion" Subject: Complicated aggregate function? 12/17/04 03:55 PM Please respond to Hjalte Hi, I would really appreciate some help with the following problem: I have a SAS dataset with 3 variables and 150000 rows. I now want to get the sum of each of the three variables, respectively. The problem is that I need to group them by decentiles, that is: I want it to make a group out of the first 1-15000 rows, a group out of the next 15001-30000 rows, and so on, until I have 10 groups with 15000 rows in each, i.e. a table with 10 rows and three columns displaying the corresponding sum in each. Is there an easy way to achieve this? I would be most grateful for any help! Best wishes, Hjalte Dam, student at the M.Sc. in IT, communication and organization at the University of Southern Denmark ```

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