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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: RE: How do I properly tell Stata this data is Panel Data?


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: How do I properly tell Stata this data is Panel Data?
Date   Sat, 13 Oct 2012 10:07:00 +0100

The easy solution was to do what I suggested.

If contrary to appearances, -year- and -quarter- were string variables
then the call to -yq()- would be

yq(real(year), real(quarter))

Otherwise, convert your string date variable to numeric with a
conversion function identified after reading -help dates and times-.

Note that you don't show the exact commands you used; see advice in the FAQ.

Nick

On Sat, Oct 13, 2012 at 2:19 AM, Andrew Nicholson <andrew5@k-state.edu> wrote:
> Thank you for your response.  I went into the original data set and created a new quarter variable that ranges from 2001q1 - 2008q4 for all counties.
>
> xtset CountryNum quarter
> This command now gives me this response "varlist:  quarter:  string variable not allowed."  Is there an easy solution to this?

From: "Nick Cox" <njcoxstata@gmail.com>

> This advice is quite incorrect: -xtset- or -tsset- will not accept
> -quarter- as a time variable, because there are repeated values within
> each panel.
>
> You are best advised to calculate a quarterly date that combines the
> two time variables.
>
> gen qdate = yq(year, quarter)
> format qdate %tq
> xtset countynumber qdate
>
> Nick
>
> On Fri, Oct 12, 2012 at 11:08 PM, Sun Yutao <yutao.sun@hotmail.com> wrote:
>
>> I think you should set the quarter as your time axis. And when you need to estimate something that is year-wide, you take sum or average depending on what you want exactly.
>
> Andrew Nicholson
>
>> Essentially my data looks as follows:
>>
>> County   CountyNumber     Year    Quarter     ......................
>> Allen     1                2001    1
>> Allen     1                2001    2
>> Allen     1                2001    3
>> Allen     1                2001    4
>> Allen     1                2002    1
>> ...       ...              ...     ...
>> Allen     1                2008    4
>> Anderson  2                2001    1
>> ...       ...              ...     ...
>> Anderson  2                2008    4
>>
>> It continues this way for 105 counties.  My question is how do I use the xtset command when I have both Year and Quarter as time variables.  County and CountyNumber are both classifying the same thing in the dataset.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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