Announcement

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

  • Create a year variable for the last year an interview was conducted

    Hello everyone!

    I want to create a variable named year to assign each individual the last year an interview was conducted. So, I have 10 waves where those individuals might have been asked, and they can be interviewed in more than one wave/year. So, in order to introduce country year variables (for multilevel analysis) I need to create this year variable for each individual, coded as the last year they answered the survey. The variables that show information for each wave where the survey was asked each year are int_year_w1 int_year_w2 (...) int_year_w8 int_year_w8ca int_year_9ca.


    Thanks in advance!


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(int_year_w1 int_year_w2 int_year_w3 int_year_w4 int_year_w5 int_year_w6 int_year_w7 int_year_w8 int_year_w8ca int_year_w9ca)
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -98 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -93 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -98 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -98 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -98 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -98 -92 -92 -92 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -98 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -93 -93 -93 -93 -93 -97 -97 -93 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -98 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -98 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -98 -98 -92 -92 -92 -92
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -98 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -98 -97 -97 -97 -97 -97 -93 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -98 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    2004 -93 -92 -97 -97 -97 -97 -97 -93 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004   . -94 -94 -94 -94 -94 -94 -94 -94
    2004 -92 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -92 -92 -97 -97 -97 -97 -97 -92 -97
    2004 -92 -92 -92 -92 -92 -97 -97 -92 -97
    2004 -97 -97 -97 -97 -97 -97 -97 -92 -97
    end
    label values int_year_w1 na_extended
    label values int_year_w2 na_extended
    label values int_year_w3 na_extended
    label values int_year_w4 na_extended
    label values int_year_w5 na_extended
    label values int_year_w6 na_extended
    label values int_year_w7 na_extended
    label values int_year_w8 na_extended
    label values int_year_w8ca na_extended
    label values int_year_w9ca na_extended
    label def na_extended -98 "Not applicable (other reason)", modify
    label def na_extended -97 "Not applicable (out of sample)", modify
    label def na_extended -93 "Not applicable (person was not listed as household member in this wave)", modify
    label def na_extended -92 "Not applicable (household did not participate in this wave)", modify
    label def na_extended -94 "Not applicable (person has an End-of-Life interview in previous waves)", modify

  • #2
    In all that data, not one instance of participation and only one year shown. What value is given with participation?

    Comment


    • #3
      I've just added the variables that account for which years the individuals have participated (it can be one or more). The value years (2004,2005... up to 2021) is the result that gives participation, the data shown is just an example of all the individuals that I have.

      Comment


      • #4
        search egen

        look at rowmax

        Comment

        Working...
        X