I want to graph a categorical variable, such as a grade distribution of letter grades. I can do this pretty easily with:
Code:
graph bar, over(grade)
Based on the help file, I think the right solution is to create a new variable and then sort by it. So I did this:
Code:
gen ordvar=1 if Grade=="F" replace ordvar=2 if Grade=="D-" replace ordvar=3 if Grade=="D" replace ordvar=4 if Grade=="D+" replace ordvar=5 if Grade=="C-" replace ordvar=6 if Grade=="C" replace ordvar=7 if Grade=="C+" replace ordvar=8 if Grade=="B-" replace ordvar=9 if Grade=="B" replace ordvar=10 if Grade=="B+" replace ordvar=11 if Grade=="A-" replace ordvar=12 if Grade=="A" replace ordvar=13 if Grade=="A+" graph bar, over(Grade, sort(ordvar))
Code:
variable mean not found
0 Response to Graph bar for categorical variable, but sorted in prespecified order
Post a Comment