Announcement

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

  • panel data - dummy variable

    Good evening everybody.
    I have a panel data set on 10 years from 2006 to 2016, whereby I have variables for the incorporation date in dd/mm/yyyy, and if the firm exit before the end of this period I have less observation(deleted years in which there were no datas). I would create a dummy for firms that have exit during this period, thus I was thinking something like =1 if incorporation date < 2006 and observation <10, or 0 otherwise. However I don't know how to apply it..
    Do you have any suggestion?
    thanks so much,
    regards.

  • #2
    Code:
    by firm_id, sort: gen byte exited = year(incorporation_date) < 2006 & _N < 10
    Replace firm_id and incorporation_date by the actual names of the corresponding variables in your data.

    Note: assumes incorporation date is in fact a Stata internal format numeric date variable. If what you have is a string, then you need to convert it first. See -help datetime- to learn about the -date()- function.

    In the future, when asking for help with code, please provide an example of your data so that nobody has to guess, for example, whether your date variable is a string or numeric, or what its name might be. When showing data examples, please use the -dataex- command to do so. If you are running version 15.1 or a fully updated version 14.2, it is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.



    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment

    Working...
    X