Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[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 <[email protected]>
To   [email protected]
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
<[email protected]> 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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index