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: Tabulation of a variable against itself lagged


From   Iulian Ihnatov <[email protected]>
To   [email protected]
Subject   Re: st: Tabulation of a variable against itself lagged
Date   Sun, 18 Sep 2011 13:48:44 +0300

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


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------

Can you generate a new variable equal to the lag and then tabulate?

best,
Robson Glasscock

On Sat, Sep 17, 2011 at 3:53 PM, Iulian Ihnatov<[email protected]>  wrote:

Dear Statalist user,

After a day of research on forums, FAQ etc. I can't find a solution for my
problem, so I ask for your help.
I have a cross-section - 190 countries/ 12 years - of the categorical
variable "regime" (takes 8 values).
I need to tabulate this variable against itself but lagged one year. The
table should look like this:

                                                    2009
  2010 |         1          2          3          4          5          6
      7          8
----------------------------------------------------------------------------------------------
         1 |        37
         2 |                    8
         3 |                              43
            1
         4 |                                          6
            1
         5 |                                                     5
         6 |                                                                6
                          1
         7 |                               1
            24           1
         8 |         1                    1
           1           48

It seams simple, but I just can't figure out how to do it, so any idea would
be highly appreciated.

--
Regards,
Iulian Ihnatov


--
Regards,
Iulian Ihnatov


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index