For anyone who is curious, Kitty's solution might have been something like
First load a somewhat miniaturized example:
1.1 1.2 1.3
2.1 2.2 2.3
3.1 3.2 3.3
Now for the array manipulation:
array ss sum1-sum3;
array mm month1-month9;
do i = 3 to 9 by 3;
ss(i/3) = sum(mm(i-2),mm(i-1),mm(i) );
put (sum :)(=);
The log reports:
sum1=3.6 sum2=6.6 sum3=9.6
But let's step back and look for easier ways to work with time series.
The prerequisite is to normalize the storage and use SAS dates, as in:
input month : monyy7. sales;
Now, if you have SAS/ETS licensed, PROC EXPAND should probably be your
first choice. But even Base SAS can handle this problem nicely. For example:
select intnx('quarter',month,0) as quarter format yyq6.,
sum(sales) as sales
group by quarter
As things get more complicated (eg, multiple series, missing values or
partial quarters), the advantage of using these conventions increases.
On Tue, 21 Feb 2006 18:09:22 -0800, Kitty Lee <kitty_lee04@YAHOO.COM> wrote:
>I already figured it out. Thanks!
>Kitty Lee <firstname.lastname@example.org> wrote: Hi All,
> I have a question regarding "do loop". If I need to get a quarterly
sales, how should I set up the do loop if the counters are not the same? I
have 10 sum variables and 30 sales variables.
> array sum sum1-sum10;
> array month month1-month30;
> sum1 = sum(of month1 month2 month3);
> sum2 = sum(of month4 month5 month6);
> sum10 = sum(of month28 month29 month30);
> Thank you!
> Yahoo! Mail
>Use Photomail to share photos without annoying attachments.
>Brings words and photos together (easily) with
> PhotoMail - it's free and works with Yahoo! Mail.