Announcement

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

  • Generating a new variable which shows "years of unemployment"

    Hey!

    I need to calculate the years of unemployment from the time period 2001 - 2012. This variable "years of unemployment" should show the sum of the total duration of unemployment in years of every person from 2001 - 2012.
    For example a person was registered as unemployed in 2001, also in 2002, but then in 2003 the person was not registered as unemployed anymore.

    I have following variables:

    - pid: describes the personal identification number
    - syear: describes the survey years, I need the years from 2001-2012
    - unemployed: describes if a person (pid) is registered as unemployed or not (1= yes, 2= no)

    Could anyone please help me to find the right command in stata to get the years of unemployment?
    I just know that I first have to sort but then I have no clue at all.

    Thank you very much.

    Regards
    Tina




  • #2
    you don't supply a data example, but here is a guess:
    Code:
    replace unemployed=0 if unemployed==2
    bysort pid: egen byte totunemp=total(unemployed)
    this will put the total in each observation (I have assumed your data are in long format; substitute "rowtotal" for "total" if in wide format)

    Comment


    • #3
      Also,

      Code:
      bysort pid: egen byte totunemp=total(unemployed == 1)

      Comment


      • #4
        Thank you for your quick answer. Just an additional question:

        I want to get the months of unemployment, instead of years of unemployment. As described above, I have the "pid" (personal identification number) and the "syear".
        Regarding this case and unemployment, here I only have the variables from t-1:

        - unemployedprevious: describes if a person was registered as unemployed in t-1 (registered as unemployed in the previous year)
        - unemployedpreviousinmonths: months from january to december (in the previous year), describes how many months a person was registered as unemployed in t-1

        Could you please tell me what I have to change in the command to get the total duration of unemployment in months of every person from 2001 - 2012.

        Thanks a lot.

        Comment

        Working...
        X