This is a stunningly simple problem and I know there is a stunningly simple answer, but I can't figure it out.
I want to graph a categorical variable, such as a grade distribution of letter grades. I can do this pretty easily with:
The problem with this is that it's out of order, with A coming before A+, B coming before B+. In addition, I would prefer to reverse it so that "F" is at the bottom.
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:
The result is that I get this error message:
Is there an alternative way to do this that I am missing? I am convinced that there is a simple solution that I can't think of.
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
Comment