Manipulating entries of a series

For questions and discussion related to reading in and working with data.

Manipulating entries of a series

Postby marcushemma » Thu Jul 19, 2012 5:38 am

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
marcushemma
 
Posts: 4
Joined: Sat Jun 12, 2010 3:12 am

Re: Manipulating entries of a series

Postby TomDoan » Thu Jul 19, 2012 9:50 am

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
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm


Return to Data: Reading, Writing, Transforming

Who is online

Users browsing this forum: No registered users and 1 guest