Dear statalisters,
is there a way to add %-signs (by code) to my stacked bar chart?
here is the code for data preperation and graph:
foreach var of varlist (Q603_1_N - Q603_7_N) {
recode `var' 3=1 1=2 6=3 2=4 5=5 4=6
}
mvdecode Q603_1_N - Q603_7_N, mv (6=.a)
foreach var of varlist (Q603_1_N - Q603_7_N) {
label define `var' 1 "gut" 2 "eher gut" 3 "teils, teils" ///
4 "eher schlecht" 5 "schlecht", modify
}
* Vorbereitung für Grafik
clonevar ta1= Q603_1_N
clonevar ta2= Q603_2_N
clonevar ta3= Q603_3_N
clonevar ta4= Q603_4_N
clonevar ta5= Q603_5_N
clonevar ta6= Q603_6_N
clonevar ta7= Q603_7_N
local ta1: var lab ta1
dis "`ta1`"
foreach var of varlist _all {
local `var`: var lab `var`
}
gen id = _n
reshape long ta, i(id)
rename ta score
*-------------------------------------------------------------------------------------------------------------------------
set scheme prognos
graph set window fontface "Franklin Gothic Book"
graph hbar (percent) if BundeslandAdressinformation== "Nordrhein-Westfalen" , over (score) over(_j, relabel ///
(1 "Werdende Eltern" 2 "Paarfamilien (Familien mit zwei Elternteilen)" 3 "Alleinerziehende (Familien mit einem Elternteil)" ///
4 "Familien mit Migrationshintergrund" 5 "Personen in Trennung/Scheidung" 6 "Sozial schwache Familien" ///
7 "Familien mit wenig Internetkenntnissen")) asyvars percentage stack ///
blabel(bar, pos(center) size(2.5) color(white) format(%2.0f)) ytitle("") ylabel( 0 "0%" 20 "20%" 40 "40%" 60 "60%" 80 "80%" 100 "100%") ///
title("") legend(pos(bottom) cols(5)) name(graph1, replace) xsize(7)
Thanks a lot! Beste regards, Tim
Related Posts with Adding % to stacked bar chart
Interpreting the intercept in a logistic regression with multiple factor variablesHi all, I am looking to calculate the odds ratios in a logistic regression where the dependent vari…
Compounding Panel DataDear all, I am trying to analyse the effect of Incentives on Electric Vehicle adoption (Panel Data)…
Creating Variable based on NAIC Digit Level match for FirmsI have a list of firms that I am comparing to each other using NAIC (Industry ID - 6 digits). I want…
Testing the OLS assumptions in relation to standard robust errorsDear all, I'm testing the OLS assumptions for a multiple cross-sectional regression model. In rela…
Mixed effects (multilevel) model vs. cluster commandHi all I want to test the association between childhood behaviour at age 6 years and earnings at age…
Subscribe to:
Post Comments (Atom)
0 Response to Adding % to stacked bar chart
Post a Comment