Hi Stata users,
I am using a Stata user written command
in Stata 17 to generate plots for categorical variable. I would specifically want to compare weighed an unweighted results but would want them to be in the same chart (i.e bar labels of the same option be adjacent to one another and have a legend differentiating the two groups) instead of the chart being produced through the by option.
Below is the code am trying to play with
Thanks in advance!
I am using a Stata user written command
Code:
catplot
Below is the code am trying to play with
Code:
sysuse auto, clear expand 2, gen(indicator) lab def indicator 0 "Unweighted" 1 "Weighted" lab val indicator indicator ta indicator drop weight gen weight = (1/runiform()) if indicator == 1 gl barsettings1 "bar(1, fcolor(navy) fintensity(inten40) lcolor(navy) lwidth(medium))" count if !mi(foreign) catplot foreign, by(indicator) blabel(bar, format(%3.0f)) l1title("") title("") ytitle("Percent") percent note("N = `:display %05.0fc `r(N)''") $barsettings1 count if !mi(foreign) catplot foreign [aweight = weight], by(indicator) blabel(bar, format(%3.0f)) l1title("") title("") ytitle("Percent") percent note("N = `:display %05.0fc `r(N)''") $barsettings1
Comment