Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Compare changes within groups in a panel dataset

    Hello everyone,

    probably an easy one for you: I use a panel data set (several groups and years per group) and want to check whether a certain status within a group changed from the first year to the last year observed. The sample period is not always the same for all groups. The characteristic I want to compare is the legal status of a company, i.e. the variable "status" would contain values such as "Ltd", "Public" etc. If the status remained the same a new variable created should take on the value 1 and 0 otherwise. Finally I would like to compare the change, i.e. how many companies (groups) have changed their legal status (e.g. 200 out of 1000 companies changed their status -> the result should yield 0.2).

    Could you help me out with the code please? Thank you!

  • #2
    For the first request, I would try
    bysort group year: generate status_change = (status==status[_n-1])

    Comment


    • #3
      This is an FAQ: http://www.stata.com/support/faqs/da...ions-in-group/

      Comment


      • #4
        Thank you very much for the quick and helpful comments.

        Comment


        • #5
          To count companies rather than observations, use egen, tag() to tag each company just once.

          Comment


          • #6
            Ronald may also be interested in taking a look at -xttrans- under -help xttab- and related entry in Stata 13.1 .pdf manual.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment

            Working...
            X