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

st: RE: Re: tsset


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Re: tsset
Date   Sun, 1 Feb 2004 16:39:37 -0000

Juan Manuel Jauregui wrote 
 
> I have a panel data of countries and years and when 
> entering the command
> 
> tsset country year
>
> I receive the error message that the string 
> is not allowed. Obviously country is a string. How can I solve this 
> problem? Do I have to create
> an id number for each country? How can I do that?

and ACHINTYA RAY replied 
 
> I faced the same problem in my work. So I took the harder 
> route and created
> a numeric ID for each country in Excel and then got the data 
> into STATA. In
> Excel, this is a piece of cake after you sort your data by 
> the country name.
> But taking the harder route saved a lot of time for me. May 
> be there is a better way out.

This is also easy in Stata. Indeed it doesn't require
even a prior sort. Use -encode-. 

. encode country, gen(Country) 
. tsset Country year 

http://www.stata.com/support/faqs/data/group.html also
gives advice in this area. 

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

*
*   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