Hi all,
I would like to understand how 'dfruit_main' & 'dvege_main' (fruit & veg consumption) changed over time. These variables were only captured in particular waves in the survey and I would like to analyse responses in Waves 9,15 and 18.
How do I ensure that I am following the same individuals in these waves?
This is what I tried but I'm losing a lot of observations and the sample sizes are not constant across waves. It may not be surprising to lose some observations as Waves 15 & 18 were fielded during the pandemic.
gen surveyp = .
replace surveyp = 1 if wave == 9
replace surveyp = 2 if wave == 15
replace surveyp = 3 if wave == 18
tab surveyp
followed by
egen present = total(surveyp), by(pidp)
keep if present==3
----------------------- copy starting from the next line -----------------------
Thanks in advance for your help with this.
Many thanks
Karen
I would like to understand how 'dfruit_main' & 'dvege_main' (fruit & veg consumption) changed over time. These variables were only captured in particular waves in the survey and I would like to analyse responses in Waves 9,15 and 18.
How do I ensure that I am following the same individuals in these waves?
This is what I tried but I'm losing a lot of observations and the sample sizes are not constant across waves. It may not be surprising to lose some observations as Waves 15 & 18 were fielded during the pandemic.
gen surveyp = .
replace surveyp = 1 if wave == 9
replace surveyp = 2 if wave == 15
replace surveyp = 3 if wave == 18
tab surveyp
followed by
egen present = total(surveyp), by(pidp)
keep if present==3
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long pidp float(surveyp dfruit_main dvege_main) byte wave 22445 . . . 6 22445 . 3 4 5 22445 . . . 4 22445 . 3 4 7 22445 . . . 8 22445 . 4 4 11 22445 1 4 4 9 22445 . . . 10 29925 . . . 6 29925 . . . 10 29925 . . . 8 29925 . 2 3 11 29925 1 2 3 9 29925 . . . 4 29925 . 2 3 7 76165 2 4 1 15 76165 . . . 12 76165 . . . 16 76165 . . . 8 76165 . . . 20 76165 . 3 2 11 76165 3 3 2 18 76165 1 4 3 9 76165 . 4 3 7 76165 . . . 19 76165 . . . 17 76165 . . . 14 76165 . . . 10 76165 . . . 13 223725 . . . 7 223725 . . . 8 280165 . . . 8 280165 . 4 4 2 280165 . . . 14 280165 . . . 16 280165 . 4 4 7 280165 . . . 3 280165 . 4 4 5 280165 . 4 4 11 280165 . . . 12 280165 . . . 4 280165 . . . 6 280165 2 4 4 15 280165 . . . 10 280165 . . . 13 280165 1 3 4 9 333205 . 2 4 11 333205 . . . 10 333205 . . . 8 333205 . 4 4 7 333205 . . . 6 333205 1 3 4 9 387605 . 4 4 5 387605 . 3 2 7 387605 . . . 6 387605 . . . 4 469205 . . . 10 469205 1 2 2 9 469205 . . . 20 469205 . 2 2 11 469205 . . . 12 469205 . . . 16 541285 . . . 6 541285 . . . 3 541285 . . . 4 541285 . . . 5 541965 . . . 3 599765 . . . 20 599765 . . . 13 599765 . 4 4 5 599765 1 4 4 9 599765 . . . 14 599765 . . . 12 599765 . . . 4 599765 . 4 4 11 599765 . . . 10 665045 . . . 8 665045 . . . 4 665045 . 2 1 11 665045 . . . 6 665045 . . . 3 665045 . 2 2 5 665045 . . . 10 732365 . . . 16 732365 3 1 2 18 732365 . 2 1 11 732365 . . . 20 732365 1 2 3 9 732365 . . . 14 732365 . . . 10 732365 . . . 12 732365 . . . 19 732365 . . . 17 732365 . . . 13 760925 . . . 11 760925 . . . 10 813285 . . . 7 813285 . . . 4 813285 . . . 6 813285 . . . 8 end
Many thanks
Karen

Comment