Announcement

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

  • Question Stata!!

    Hello,

    Do you have any idea of how can I create a variable that is equal to the nº of years a person has been following a given firm? Like for example, if the sample starts in 2015, then in 2020, the person can have a maximum experience of 5 years, with any given company?

    Thank you

  • #2
    Welcome to Statalist Maria. The answer to your question depends on what your data looks like exactly. To tell us that you need to give us an abstract from your data. See the Statalist FAQ (black bar near the top of this page) for how to do that.

    Also the title of your question is not very informative. Finding a good and informative title is important, as the people who want to help just browse a list of titles and decide which post to open based on that.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      I don't have a good idea of what your dataset looks like. A very wild guess is hat

      Code:
      bysort personid (year) : gen wanted = year - year[1]
      may help. If not, and you don't get a better answer then you may need to do what we ask and give a data example. See https://www.statalist.org/forums/help#stata

      Comment


      • #4
        Maria:
        welcome to this forum.
        Do you mean something along the following lines?
        Code:
        . use "https://www.stata-press.com/data/r16/nlswork.dta"
        (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
        
        . bysort idcode: egen presence_year=count(year)
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment

        Working...
        X