I have a dummy variable (var) for 4 diffrent years. I want to have a bar chart that shows me the percantage for yes's and no's for each of the 4 years. I tried it using two generated variables:
gen var0 = var
replace var0 = . if var0 != 0
gen var1 = var
replace var1 = . if var1!= 1
replace var0 = . if var0 != 0
gen var1 = var
replace var1 = . if var1!= 1
Code:
graph bar (percent) var0 var1 if year== 2002 & condition== 1 | year== 2007 & condition== 1 | year== 2012 & condition== 1 | year== 2017 & condition== 1, over (year)
The Output that Stata gives me is the percantage of no's/yes's over the 4 years and not for each year: (no's year 1) divided by (no's year 1 + no's year 2 ...) . But I want to have: (no's year 1) divided by (no's year 1 + yes's year 1).
Thanks in advance
Ben
0 Response to bar chart dummy percent
Post a Comment