Announcement

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

  • Age group in a longitudinal survey

    Hi I want to restrict my analysis sample to those individuals who were between 5 and 14 in wave 1 of a longitudinal survey. The wave 1 was conducted in 2004-05 and wave 2 was conducted in 2011-12. How can I do that?

    Code:
     dataex HHPBASE SURVEY age
    
    ----------------------- copy starting from the next line -----------------------
    
    
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double HHPBASE byte SURVEY int age
    101020101001 1 50
    101020101002 1 45
    101020101003 1 22
    101020101005 1 13
    101020101006 1  7
    101020102001 2 76
    101020102001 1 69
    101020102003 1 35
    101020102003 2 42
    101020102004 2 40
    101020102004 1 33
    101020102005 1 14
    101020102005 2 20
    101020102006 2 19
    101020102006 1 12
    101020102007 1  6
    101020102007 2 13
    101020102008 2 37
    101020102008 1 31
    101020102009 1 26
    101020102009 2 33
    101020102010 2 13
    101020102010 1  6
    101020102011 1  1
    101020102011 2  8
    101020102012 1 24
    101020102012 2 31
    101020102013 1 19
    101020102013 2 26
    101020102014 1  1
    101020102014 2  8
    101020102015 1 59
    101020102015 2 65
    101020103001 1 37
    101020103001 2 45
    101020103002 2 43
    101020103002 1 36
    101020103003 2 23
    101020103003 1 15
    101020103004 2 20
    101020103004 1 13
    101020103005 1 10
    101020103005 2 17
    101020103006 2 14
    101020103006 1  7
    101020103007 1  5
    101020103007 2 12
    101020104001 1 50
    101020104001 2 57
    101020104002 1 40
    101020104002 2 47
    101020104003 1 13
    101020104003 2 20
    101020104004 2 14
    101020104004 1  7
    101020104005 2 13
    101020104005 1  6
    101020105002 2 50
    101020105002 1 43
    101020105003 2 38
    101020105003 1 28
    101020105006 1 20
    101020105006 2 27
    101020105007 2 23
    101020105007 1 16
    101020105008 1 11
    101020105008 2 18
    101020105009 1  9
    101020105009 2 16
    101020105010 1  6
    101020105010 2 12
    101020106001 1 65
    101020106001 2 72
    101020106012 2 39
    101020106012 1 33
    101020106013 1 30
    101020106013 2 37
    101020106014 1 27
    101020106014 2 33
    101020106015 1 20
    101020106015 2 27
    101020107001 1 45
    101020107001 2 52
    101020107002 1 40
    101020107002 2 42
    101020107003 1 19
    101020107003 2 26
    101020107004 2 24
    101020107004 1 17
    101020107006 1 13
    101020107006 2 20
    101020107007 2 18
    101020107007 1 11
    101020107008 2 16
    101020107008 1  9
    101020107009 2 15
    101020107009 1  8
    101020108001 1 35
    101020108001 2 42
    101020108002 2 37
    end
    label values SURVEY SURVEY
    label def SURVEY 1 "IHDS1 1", modify
    label def SURVEY 2 "IHDS2 2", modify
    ------------------ copy u

  • #2
    Code:
    egen id = group(HHPBASE)  //HHPBASE is long so this helps you see it in the data; not required.
    egen agewave1 = min(age), by(id)  //could use HHPBASE rather than id in by
    now you can restrict on agewave1.

    sample is not balanced.

    Comment


    • #3
      Raphael:
      as an aside to George's helpful advice, you can select the observations you're interested in via:
      Code:
      gen counter=1 if age >=4 & age<=14 & SURVEY==1
      Then you need an individual -id- to move forward.
      Kind regards,
      Carlo
      (StataNow 18.5)

      Comment


      • #4
        Thank you very much

        Comment

        Working...
        X