Date: Thu, 16 Jun 2005 11:27:08 -0400
Reply-To: Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Subject: Re: SAS help on data analysis
On Thu, 16 Jun 2005 11:01:06 -0400, Mike Smith <del101679@YAHOO.COM> wrote:
>Hi. I wanted to compute the average of every five numbers in my data set in
>SAS. How do I do it? Thanks.
Thats not clear: where are that five numbers? In one obs? in five?
If it is so, that you want to get buckets with 5 obs each and want to get
the average of a numeric variable of that buckets, you might do something
like that:
data a;
do number=1 to 1000;
output;
end;
run;
data x;
retain xx 0;
set a;
if mod(_n_,5)=1 then xx+1;
run;
proc summary data=x nway missing;
class xx;
var number;
output out=avg mean=;
run;
It is: add a value like xx which has always the same content for 5 obs (0
for the first five, 1 for the next five, ...
Then use proc summary to get your statistic (mean=).