Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bar graph with descending order of counts

    Hi all.
    I have a simple bar graph to make in Stata. I want to make a frequency bar graph of rep78 using the auto dataset in which the bars are ordered in descending order of rep78 frequencies.
    Code:
    sysuse auto, clear
    tab rep78, sort m
    Here is what I want in Stata. This I made in Excel.
    Click image for larger version

Name:	rep78.png
Views:	1
Size:	12.6 KB
ID:	1738472

  • #2
    I used this code and it works. But I think there must be a more efficient way to handle this type of bar.
    Code:
    sysuse auto, clear
    contract rep78, freq(f)
    gsort -f
    graph bar (mean) f, over(rep78, sort(f) descending) ytitle(`"count"') caption(`"rep78"', position(6))
    Kindly suggest.

    Comment


    • #3
      Code:
      sysuse auto, clear
      gr bar (count), over(rep78, sort(1) descending  relabel(6 "Missing")) missing ytitle(count) caption(rep78, pos(6))
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	24.9 KB
ID:	1738475

      Comment


      • #4
        Oh wow! That was simple. Thank you very much.

        Comment

        Working...
        X