简体   繁体   English

在 STATA 中为分类变量绘制条形图

[英]Plotting bar plots for categorical variables in STATA

I have a survey data baseline and endline.我有一个调查数据基线和终点线。 I am trying to plot bar plot for qualification of the respondent in each group (baseline/endline).我正在尝试 plot 栏 plot 来确定每个组(基线/终点)中的受访者的资格。

I am using the following code:我正在使用以下代码:

 graph bar, over(qualification) over(time)

It is giving me different output from what I want.它给了我与我想要的不同的 output。 我的输出 I want the bars for endline and baseline for each category to be present parallel.我希望每个类别的端线和基线条平行存在。

I am also attaching a reference picture to get the better idea about what I want.我还附上了一张参考图片,以更好地了解我想要什么。 我想要的输出

The order of the over options of graph bar matters. graph barover选项的顺序很重要。

Consider this example:考虑这个例子:

clear
input x str1 a b
1 "a" 1
2 "a" 2
3 "b" 1
4 "b" 2
end

graph bar x, over(a) over(b) title("over(a) over(b)")
graph bar x, over(b) over(a) title("over(b) over(a)")

示例1 示例2

It looks like you need to swap the order of your over options.看起来您需要交换您的over选项的顺序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM