Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Declaring time series


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: Declaring time series
Date   Thu, 13 May 2004 16:18:36 +0100

Thanks for this. 

I did this to get something like your data: 

clear 
set obs 120 
egen c_code = seq(), block(12) 
egen m = seq(), to(12) 
gen date = 1960 + m/100
tostring date, replace format(%3.2f) force

and then I tried your code 

generate year = real(substr(date,1,4))
generate month = real(substr(date,6,2))
generate paneldate = ym(year,month)
format paneldate %tm
tsset c_code paneldate, monthly

and it worked. 

Therefore, I suggest 

. duplicates report c_code paneldate 

and other applications of -duplicates-. 

Nick 
n.j.cox@durham.ac.uk 

jdubas@nd.edu
 
> Here is what I tried to do:
> I had the data originally like this:
> 1960.01
> 1960.02
> 
> So:
> generate year = real(substr(date,1,4))
> generate month = real(substr(date,6,2))
> generate paneldate = ym(year,month)
> format paneldate %tm
> 
> When I tried to:
> tsset c_code (my panel data operator) paneldate, monthly
> 
> It claims error 451, repeated time values within panel.
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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   |   What's new   |   Site index