Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Adding observations to the beginning of a time-series or panel dataset


From   Scott Merryman <scott.merryman@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Adding observations to the beginning of a time-series or panel dataset
Date   Thu, 12 Aug 2010 16:07:38 -0500

With just a time series you could:

webuse tsappend1, clear
count
local obs = r(N)
tsset
local add = tm(`=r(tmins)') - tm(1955m2)
set obs `=`obs' + `add''
mark tag if t <.
gsort tag t
replace t2 = _n - `add'
drop tag
tsset

Scott


On Thu, Aug 12, 2010 at 3:02 PM, Dimitriy V. Masterov
<dvmaster@gmail.com> wrote:
> I am trying to add additional time observations to the beginning of a
> panel data set. I am really trying to replicate what -tsappend,
> first()- would do if it existed.
>
> Using tsappend works if you want to add data at the end, but not at
> the beginning. To simplify things, tsappend1.dta is a time-series data
> set that spans 1960m2 to 2000m1. The first tsappend works, while the
> second does not:
>
> #delimit;
> set more off;
> webuse tsappend1, clear;
> tsset;
>
> tsappend, last(2005m2) tsfmt(tm);
> tsset;
>
> tsappend, last(1955m2) tsfmt(tm);
> tsset;
>
> Any suggestions?
>
> Dimitriy
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index