Announcement

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

  • Lagged variables: transition from one condition to another

    Dear users,
    I am new of longitudinal analysis and I am running into a problem that may be easy for you:

    I need to create one variable which assume values = 1 if the case has passed from the condition of being employed(t-1) to the unemployment(t). All the other transitions have to be coded with 0.

    Here an example of my data:


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long(pidp apidp) int panel_id byte(wave status)
    68028575 68028567 214 1 1
    68028575 68028567 214 2 0
    68028575 68028571 215 1 1
    68028575 68028571 215 2 0
    68049655 68049651 317 1 2
    68049655 68049651 317 2 0
    end
    the variable status is: 0 = unemployed
    1 = employed
    2 = student

    I am working with dyads, so each couple parent-son\daughter is identified by a unique id (panel_id)

    Do you have any clue about that?

    thanks a lot, G

  • #2
    I think I solved with
    gen transi = ( status == 0 & L.status==1 ) ///
    if !missing(L.status)

    sorry for this post, but maybe someone will find it useful.

    G

    Comment


    • #3
      Never apologize for posting. The probability is very high that somebody else will have a very similar question in the future and will come here searching for an answer. You've made it possible for them to find it. Thank you!!!

      Comment


      • #4
        Notice that this simplifies to

        Code:
        gen transi = status == 0 & L.status == 1
        as if the previous value is 1 then it is necessarily not missing too.

        Comment

        Working...
        X