Hello,
I have data which looks like this:
I want to generate a new variable indicating the percentage of observations that are 'VTCS' ovservations in each year i.e VTCS==1. So for example since in 2009 25% of observations are VTCS observations (1/4) then the variable would take the value 25 for all observations in 2009.
So the new data would look like this :
How can I implement something like this?
Essentially I want to plot a twoway graph with the share of observations that are VTCS on the y axis, and year on the x axis.
Thanks,
Jad
I have data which looks like this:
Year | VTCS |
2009 | 0 |
2009 | 0 |
2009 | 1 |
2009 | 0 |
2010 | 1 |
2010 | 1 |
2010 | 0 |
2010 | 0 |
2011 | 0 |
2011 | 0 |
2011 | 0 |
2011 | 0 |
I want to generate a new variable indicating the percentage of observations that are 'VTCS' ovservations in each year i.e VTCS==1. So for example since in 2009 25% of observations are VTCS observations (1/4) then the variable would take the value 25 for all observations in 2009.
So the new data would look like this :
Year | VTCS | New Variable |
2009 | 0 | 25 |
2009 | 0 | 25 |
2009 | 1 | 25 |
2009 | 0 | 25 |
2010 | 1 | 50 |
2010 | 1 | 50 |
2010 | 0 | 50 |
2010 | 0 | 50 |
2011 | 0 | 0 |
2011 | 0 | 0 |
2011 | 0 | 0 |
2011 | 0 | 0 |
How can I implement something like this?
Essentially I want to plot a twoway graph with the share of observations that are VTCS on the y axis, and year on the x axis.
Thanks,
Jad
Comment