Date: Tue, 22 Feb 2005 19:51:06 +0000
Reply-To: datametric@CLUB-INTERNET.FR
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: SUBSCRIBE SAS-L Stephane <datametric@CLUB-INTERNET.FR>
Subject: Re: rolling aggregation
Content-Type: text/plain; charset=ISO-8859-1
Curious objective....
based on the sashelp.class data for the work.
you want to mix something like this :
proc sql noprint;
create table test1 as select sex, sum(age) as sum_age from sashelp.class group by sex; quit;
data test2;
set sashelp.class;
if mod(_n_,3)=0 then output;
keep age ;
rename age=new_age;
run;
data test3;
merge sashelp.class test1 test2;
run;
But, very curious question....
Stéphane.
----Message d'origine----
>Date: Tue, 22 Feb 2005 12:32:36 -0500
>De: Wing Wah <wing.tham03@PHD.WBS.AC.UK>
>Sujet: Re: rolling aggregation
>A: SAS-L@LISTSERV.UGA.EDU,
>Copie à: Wing Wah <wing.tham03@PHD.WBS.AC.UK>
>
>i am so sorry about the example that i have given. This is what it should
>be. I am trying to aggregate the first three terms of the 'vol',that
>explains why i get a 6 for 'aggrvol' on the first row. 9 is calculated by
>adding the 3-6th terms of the 'vol'. The 'new price' is just the 3rd, 6th,
>9th, 12th and 15th term of the 'price'
>
>obs vol price aggrvol new price
>1 2 11 6 12
>2 2 11 9 12
>3 2 12 12 12
>4 3 13 15 14
>5 3 11 18 18
>6 3 12
>7 4 14
>8 4 12
>9 4 12
>10 5 11
>11 5 16
>12 5 14
>13 6 13
>
>
>sorry for the unclear example i have given previously. Thank you for asking.
>
>Regards
>Wing Wah
>
>
|