Announcement

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

  • Assistance: Panel data - change in value over survey waves

    Hi,

    I have an individual panel data survey in Stata which includes 8 survey waves.
    • Xwaveid represents each individual’s unique identifier
    • Wave represents the survey wave
    • total_obs_n (toatal_obs_~n) represents the total number of survey waves each individual participant participated in
    • change_in_hours (change_in_~s) represents the change in the number of hours the participant works between each survey
    • hours_work_week (hours_work_~k) represents the number of hours the individual works (on average) each week
    • reduce_workload_likely (reduce_wor~y) is a binary variable that equals 1 if the individual stated that they are likely to reduce their workload and 0 if not (only available in waves 2, 3 and 4).
    I am interested in determining whether those who stated in wave 2 that they are likely to reduce their workload (i.e. =1) actually reduced their workload. In essence, I want to minus hours_work_week in wave 4 from hours_work_week in wave 2 for each participant (I also need to do this for wave 3 in case the participant did not participate in wave 4). Ideally, this would create two additional variables – one for hours worked in wave 4 less hours worked in wave 2, and one for hours worked in wave 3 less hours worked in wave 2.

    I would be very grateful if someone could provide assistance on how I can create these two additional variables.

    Thank you in advance.

    Click image for larger version

Name:	Stata.PNG
Views:	2
Size:	17.8 KB
ID:	1425997
    Attached Files

  • #2
    Code:
    isid xwaveid wave, sort
    by xwaveid: egen workload_wave4 = max(cond(wave == 4, hours_work_week, .))
    by xwaveid: egen workload_wave3 = max(cond(wave == 3, hours_work_week, .))
    Please refer to the FAQ. The posting of screenshots to show data examples it not really helpful. They are often unreadable. Even when, as in this case, they can be read, if those who want to help you want to test their proposed solutions, it is not possible to import data from a screenshot into Stata. The helpful way to show example data is with the -dataex- command, which is explained in FAQ #12. Please use it whenever you post example data in the future. It enables those who respond to your posts to create a complete and faithful replica of your Stata example with a simple copy/paste operation.

    Because you showed your example only through a screenshot, I was not able to test my code on your data. I have high confidence in the logic of what I wrote, but I offer no guarantee against typos, unbalanced parentheses, etc.

    Comment

    Working...
    X