0% found this document useful (0 votes)
30 views

Graph Bar Mean Price Over Repair

This document discusses using the over option in Stata to create bar graphs of categorical variables. It shows that the over option can be used to create a bar for each value of a specified categorical variable, with the bar height representing the mean of a quantitative variable. Bar graphs can be made over one or two categorical variables. Reversing the order of multiple over options impacts the graph. Label overlapping can be avoided by adjusting label angles. The nofill option excludes categories with no observations.

Uploaded by

morry123
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Graph Bar Mean Price Over Repair

This document discusses using the over option in Stata to create bar graphs of categorical variables. It shows that the over option can be used to create a bar for each value of a specified categorical variable, with the bar height representing the mean of a quantitative variable. Bar graphs can be made over one or two categorical variables. Reversing the order of multiple over options impacts the graph. Label overlapping can be avoided by adjusting label angles. The nofill option excludes categories with no observations.

Uploaded by

morry123
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

But you can use the over option to get one bar for each value of a categorical variable

you
choose, with the height of each bar equal to the value of the stat_choice you chose for
the quantitative variable you specified:

I. GRAPH BAR (MEAN) PRICE, OVER(REPAIR)

And you can make a similar bar graph over two different categorical variables:

II. GRAPH BAR (MEAN) PRICE, OVER(REPAIR) OVER(ORIGIN)

Compare that to what happens if you type the over(repair) and over(origin) in the
reverse order:

III. GRAPH BAR (MEAN) PRICE, OVER(ORIGIN) OVER(REPAIR)

You can avoid the overlapping labels for “Domestic” and “Foreign” by inserting another
option inside the over(origin)option:

IV. GRAPH BAR (MEAN) PRICE, OVER(ORIGIN, LABEL(ANGLE(45)))


OVER(REPAIR)

You can get Stata to leave out the categories with no observations—i.e., (repair=F &
origin=”Foreign”) and (repair=D & origin=”Foreign”)

V. GRAPH BAR (MEAN) PRICE, OVER(ORIGIN, LABEL(ANGLE(45)))


OVER(REPAIR) NOFILL
2

But you can use the over option to get one bar for each value of a categorical variable you
choose, with the height of each bar equal to the value of the stat_choice you chose for the
quantitative variable you specified:

graph bar (mean) price, over(repair)

And you can make a similar bar graph over two different categorical variables:

graph bar (mean) price, over(repair) over(origin)

Compare that to what happens if you type the over(repair) and over(origin) in the
reverse order:

graph bar (mean) price, over(origin) over(repair)

You can avoid the overlapping labels for “Domestic” and “Foreign” by inserting another option
inside the over(origin)option:

graph bar (mean) price, over(origin, label(angle(45)))


over(repair)

You can get Stata to leave out the categories with no observations—i.e., (repair=F &
origin=”Foreign”) and (repair=D & origin=”Foreign”)

graph bar (mean) price, over(origin, label(angle(45)))


over(repair) nofill

You might also like