Page 1 of 1

Creating sums of series

Posted: Thu May 17, 2018 4:00 am
by Marcus
I have a number of series, named sharedkah to sharedkth for the period 2000 to 2016.
I would like to sum the series for each year into a new series , "sumdk", which then would have the sum of all series 2000-2016.

I can do it by matrices but I think there's an easier way.
However, the below didn't work.

sstat / %slike("sharedk*")>>sumdk.

Any suggestions would be greatly appreciated.

Re: Creating sums of series

Posted: Thu May 17, 2018 9:32 am
by TomDoan
The SSTATS won't do the implied loop over the series. Assuming I understand you correctly, you would like something like:

compute allsum=0.0
dofor s = %slike("sharedk*")
sstats / s{0}>>thissum
compute allsum=allsum+thissum
end dofor s

Re: Creating sums of series

Posted: Fri May 18, 2018 2:54 am
by Marcus
Almost.
That yields a sum for all the years.

What I'm trying to do is to create a series of sums for every year.

Re: Creating sums of series

Posted: Fri May 18, 2018 6:56 am
by TomDoan
That would be

set allsum = 0.0
dofor s = %slike("sharedk*")
set allsum = allsum+s{0}
end dofor s

Re: Creating sums of series

Posted: Tue May 22, 2018 8:17 am
by Marcus
Yes it would.

thanx