I am a beginner Stata user. For a research project, whose information I must unfortunately keep confidential, I am trying to adjust a bar graph so that the order of the bars are "Increase", "Same", "Decrease" instead of the default alphabetical "Decrease", "Increase", "Same".

To create this graph, I load in my cleaned dataset and run:

graph bar, by(byvar) over(groupvar) .

In an attempt to try to re-order the bars, I ran:

gen order=1 if groupvar=="Increase"
replace order=2 if groupvar=="Same"
replace order=3 if groupvar=="Decrease"
graph bar, by(byvar) over(groupvar, sort(order)) .

I get the error message "variable mean not found".

How should I fix this?

(Apologies if this is too difficult to answer without being able to see the graph and data.)