Creating sums of series

For questions and discussion related to reading in and working with data.
Marcus
Posts: 21
Joined: Wed May 19, 2010 5:12 am

Creating sums of series

Unread post 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.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Creating sums of series

Unread post 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
Marcus
Posts: 21
Joined: Wed May 19, 2010 5:12 am

Re: Creating sums of series

Unread post 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.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Creating sums of series

Unread post by TomDoan »

That would be

set allsum = 0.0
dofor s = %slike("sharedk*")
set allsum = allsum+s{0}
end dofor s
Marcus
Posts: 21
Joined: Wed May 19, 2010 5:12 am

Re: Creating sums of series

Unread post by Marcus »

Yes it would.

thanx
Post Reply