Announcement

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

  • How to identify individuals that transition from a state of unemployment to employment?

    Hi all,

    I am performing a study of unemployment duration and I have more than 300k observations. Although, I am only interested in individuals that transition from a state of unemployment to employment. For that I have various id's for the same individual and I associated the state of employment to 1 and unemployment to 2. How can I identify those individuals?

    I am sorry if the question is too simple, but I don't understand much about stata.

    Thanks in advance,
    Bárbara

  • #2
    Please read the Forum FAQ for excellent advise on how to post your questions in a way that maximizes your chance of a timely and helpful response. Among the things you will learn there:

    1. When asking for help with code, it is essential to show an example of your data. The solution to your problem often depends on details of the data that are difficult or impossible to describe in words or even show in a table.

    2. The effective way to show example data is by using the -dataex- command. 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


    • #3
      Like, for example:

      Code:
      clear all
      input id state
      101    1
      101    2
      102    1
      103    2
      103 1
      103 2
      103 1
      104    2
      104    1
      105 2
      106 1
      107 1
      107 2
      107 1
      end
      list, sepby(id)
      sort id, stable
      tempname f
      by id: generate `f'=1 if state==1 & state[_n-1]==2
      collapse (min)flag=`f', by(id)
      list, sepby(id)

      Comment


      • #4
        Welcome to Statalist, Bárbara.

        Here is some made up data and some sample code that may point you in a helpful direction.
        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input float(id year state)
        101 2010 1
        101 2011 1
        101 2012 1
        102 2010 1
        102 2011 2
        102 2012 2
        103 2010 2
        103 2011 1
        103 2012 1
        104 2010 1
        104 2011 2
        104 2012 1
        end
        label values state state
        label def state 1 "employed", modify
        label def state 2 "unemployed", modify
        bysort id (year) : generate changed = state==1 & state[_n-1]==2
        bysort id (year) : egen want = max(changed)
        list, sepby(id) noobs
        Code:
        . list, sepby(id) noobs
        
          +------------------------------------------+
          |  id   year        state   changed   want |
          |------------------------------------------|
          | 101   2010     employed         0      0 |
          | 101   2011     employed         0      0 |
          | 101   2012     employed         0      0 |
          |------------------------------------------|
          | 102   2010     employed         0      0 |
          | 102   2011   unemployed         0      0 |
          | 102   2012   unemployed         0      0 |
          |------------------------------------------|
          | 103   2010   unemployed         0      1 |
          | 103   2011     employed         1      1 |
          | 103   2012     employed         0      1 |
          |------------------------------------------|
          | 104   2010     employed         0      1 |
          | 104   2011   unemployed         0      1 |
          | 104   2012     employed         1      1 |
          +------------------------------------------+
        With that said, let me offer some advice. Since you say there is much about Stata you don't understand, I assume you are a new user.

        When I was a new user of Stata, and there was nothing I understood, I started - as others here did - by reading my way through the Getting Started with Stata manual relevant to my setup. Chapter 18 then gives suggested further reading, much of which is in the Stata User's Guide, and I worked my way through much of that reading as well. All of these manuals are included as PDFs in the Stata installation (since version 11) and are accessible from within Stata - for example, through Stata's Help menu. The objective in doing this was not so much to master Stata as to be sure I'd become familiar with a wide variety of important basic techniques, so that when the time came that I needed them, I might recall their existence, if not the full syntax, and know how to find out more about them in the help files and manual.

        Stata supplies exceptionally good documentation that amply repays the time spent studying it - there's just a lot of it. The path I followed surfaces the things you need to know to get started in a hurry and to work effectively.

        And also let me offer some advice about getting the most out of Statalist.

        Please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post, looking especially at sections 9-12 on how to best pose your question.

        Even the best descriptions of data are no substitute for an actual example of the data. My sample data is no more than a guess as to what your data is like. If my guess was wrong, you will have more work to do to adapt my code to your actual data.

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

        If you are running version 15.1 or a fully updated version 14.2, dataex is already part of your official Stata installation. If not, run ssc install dataex to get it. Either way, run help dataex and 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.

        The more you help others understand your problem, the more likely others are to be able to help you solve your problem.




        Comment


        • #5
          Thank you very much for all the responses. I managed to make it work with your codes and your help!
          I will also read the Statalist FAQ and the stata manual.

          Best regards,
          Bárbara

          Comment

          Working...
          X