Page 1 of 1

Manipulating entries of a series

Posted: Thu Jul 19, 2012 5:38 am
by marcushemma
Hi,

I'm comparing durations of three recessions for the same series (y) since 1990. The comparisions are made in terms of percentage deviations from the peaks before the recessions and durations in months before pre-crisis peaks are reached again.

Out of this series, y, I have created three series: Crisis1, crisis2 and crisis3. They begin with the value of zero at different dates indicating the peaks before the recessions, e.g. 1992:8, 2000:12 and 2008:1.
What I want to do is the following.

1) Create three new series, without dates, with entries from 1 to say 100, indicating durations of the recessions.
2) Make the three series, crisis1-crisis3, all start at entry one so that they can be graphed starting at the same entry.

It's easy to do this by first exporting to an excel file, rearrange the series so that they have the same first entry and then import the file and graph them but it wouild be better if there's a way to do it without exporting and importing.

any help would be greatly appreciated

/Marcus

Re: Manipulating entries of a series

Posted: Thu Jul 19, 2012 9:50 am
by TomDoan
This looks like a bit more than you need, but it gives you the idea.

Code: Select all

open data haversample.rat
calendar(q) 1959
data(format=rats) 1959:1 2006:4 dgnp fm2 gdph ih lr
*
set loggdp = log(gdph)
@nbercycles(peaks=peaks)
*
set locations = %if(peaks,t,%na)
@uniquevalues(values=peakvalues) locations
compute npeaks=%size(peakvalues)
*
dec vect[series] frompeak(npeaks)
dec vect[strings] peakdates(npeaks)
do i=1,npeaks
   compute crisis=fix(peakvalues(i))
   set frompeak(i) 1 20 = loggdp(crisis-1+t)-loggdp(crisis)
   compute peakdates(i)=%datelabel(crisis)
end do i
*
list iser = frompeak
graph(number=0,key=attached,klabels=peakdates) npeaks 
cards iser 1 8