Suppose there is a categorical variable which has values of 1, 2, 3 representing different groups. If I want to display frequencies of different groups, I can use -catplot-(SSC) command. However, If there are several similar categorical variables and I want to graph frequencies of different groups of all these categorical variables, it seems that the -catplot- command do not allow varlist. To make it more understandable, you can try these codes, and what I want is to graph all three resulting bar plots in one graph. Example data is provided in the second code.
Code:
catplot a1, blabel(bar, format(%9.1f)) name(a1) catplot b1, blabel(bar, format(%9.1f)) name(b1) catplot c1, blabel(bar, format(%9.1f)) name(c1)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(a1 b1 c1) 2 1 2 1 2 1 2 2 2 2 2 1 2 2 2 2 1 1 1 2 2 3 3 3 2 2 2 2 2 1 1 2 2 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 1 1 2 2 1 1 2 1 2 3 3 3 1 2 2 2 2 1 1 1 2 1 1 1 1 2 2 2 2 1 1 2 2 1 2 1 1 2 2 2 2 1 end label values a1 size label values b1 size label values c1 size label def size 1 "big", modify label def size 2 "small", modify label def size 3 "medium", modify
0 Response to how to graph bar of categorical variables
Post a Comment