Hi,
I am working with the V-Party dataset, where the variable v2pagovsup shows if a party (v2paid) was in government or opposition at a specific point in time. However, this data is only given for the first date in the electoral cycle – the rest of the time there are no observations. I would like to carry forward the last known observation on v2pagovsup for each party so that it covers the whole electoral cycle.
I have tried doing this using the following code
The code runs without problems and the number of observations on v2pagovsup increases. However, most years still lack observations.
Does anyone have any ideas on what might be wrong?
Thanks in advance.
I am working with the V-Party dataset, where the variable v2pagovsup shows if a party (v2paid) was in government or opposition at a specific point in time. However, this data is only given for the first date in the electoral cycle – the rest of the time there are no observations. I would like to carry forward the last known observation on v2pagovsup for each party so that it covers the whole electoral cycle.
I have tried doing this using the following code
Code:
* Sort the data by party and year sort v2paid year historical_date * Declare data as time series tsset v2paid year * Fill in missing observations for each party and each year fillin v2paid year * Carry the last known value of v2pagovsup forward for each party bysort v2paid (year): replace v2pagovsup = v2pagovsup[_n-1] if missing(v2pagovsup)
Does anyone have any ideas on what might be wrong?
Thanks in advance.
Comment