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: Tabulation of a variable against itself lagged
From
Robson Glasscock <[email protected]>
To
[email protected]
Subject
Re: st: Tabulation of a variable against itself lagged
Date
Sun, 18 Sep 2011 08:59:36 -0400
Also see -help xtset- for panel data.
Even after properly declaring the time element of the data, I received
an error when trying to use the lag operator within the tabulate
command. I ended up generating a new variable, regime_2, equal to the
lag of regime and then tabulating regime and regime_2.
best,
Robson Glasscock
On Sun, Sep 18, 2011 at 7:30 AM, Partho Sarkar
<[email protected]> wrote:
> You need to use -tsset- to declare your data as a time series, or in
> this case, a panel data, before you can use time series operators.
> See -help tsset-
>
> On Sun, Sep 18, 2011 at 4:18 PM, Iulian Ihnatov <[email protected]> wrote:
>> Thank you, Robson!
>> The solution seems obvious, but I think my data may have an unappropriate
>> structure.
>> Let me explain. I had csv file which I imported in Stata, with the following
>> structure:
>>
>> countryname
>> indicatorname
>> y1999
>> y2000
>> ...........
>> y2010
>>
>> I imported and structured the data to match other series that I use in my
>> research, as follows:
>> * import data
>> insheet using regimuri.csv, delimiter(";")
>> * structure data
>> gen id1=_n
>> reshape long y, i(id1) j(year)
>> encode indicatorname, gen(varnum)
>> drop indicatorname
>> egen id2=group(countryname year)
>> reshape wide y, i(id2) j(varnum)
>> rename y1 regime
>>
>> Now my data looks like:
>> id1
>> id2
>> year
>> countryname
>> regime
>>
>> If I use time series operators I get errors:
>> E.g: -tabulate regime L.regime- "time-series operators not allowed"
>> -gen regime1=L.regime- "time variable not set"
>>
>> Have I been wrong in transforming the data? Any help would be highly
>> appreciated.
>>
>> Yours sincerely,
>> Iulian Ihnatov
>>
>
> *
> * 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/
>
*
* 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/