Announcement

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

  • Event History Analysis

    Hi,
    I have a longitudinal data from 2004 to 2010.
    I need to follow only individuals from the year 2004 onwards. The individuals have specific id's. Is there a specific code I could use to keep only the individuals who exists only in 2004 onwards and get off the rest? For instance new individuals entering the dataset from say 2005 onwards should NOT be excluded without deleting everything.

  • #2
    Suppose you have a variable named year that takes the values 2004 through 2010 and a variable named ID that gives the individual's identifier.
    Code:
    by ID (year), sort: keep if year[1]==2004
    will keep all the observations for only those individuals for which their first year in the data is 2004. Any individual who entered after 2004 will not be kept.

    Comment


    • #3
      Thank you. I'll run this

      Comment


      • #4
        Hi @William Lisowski, will this eliminate all the other variables in the process or simply keep the variables and eliminate the individuals entering from 2005 with their respective variables?

        Comment


        • #5
          You should read the output of
          Code:
          help keep
          which will describe the keep and drop commands.

          The short summary is that the keep and drop commands each operate on variables or on observations, but not on both in a single command.

          I'm thinking perhaps you have used keep or drop to remove variables in the past without reading the documentation and understanding that they each serve two tasks.

          Comment

          Working...
          X