Announcement

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

  • Data Table for Graph

    Hi helpful folks!

    I've generated a histogram showing the frequency of a continuous variable using Stata 15.1. I've been asked to provide the corresponding data table. I feel like this is a simple task, but I'm having trouble getting it done.

    Is there a way to display/generate the table of data points that generates a graph?

    Thank you,
    Kathy

  • #2
    Code:
    help tab
    E.g.:
    Code:
    sysuse auto, clear
    tab rep78
    Edit: I see its a continuous variable. that might give fairly long frequency tables. In that case, consider creating groups first, then tabbing.

    Comment


    • #3
      Code:
      . sysuse auto, clear
      (1978 Automobile Data)
      
      . histogram mpg, start(10) width(2)
      (bin=16, start=10, width=2)
      
      . help twoway__histogram_gen
      
      . twoway__histogram_gen mpg, start(10) width(2) gen(h x)
      
      . l x h if !missing(x, h)
      
           +---------------+
           |  x          h |
           |---------------|
        1. | 13   .0135135 |
        2. | 15   .0540541 |
        3. | 17   .0540541 |
        4. | 19   .1148649 |
        5. | 21   .0540541 |
           |---------------|
        6. | 23   .0540541 |
        7. | 25   .0608108 |
        8. | 27   .0202703 |
        9. | 29    .027027 |
       10. | 31   .0202703 |
           |---------------|
       11. | 35   .0202703 |
       12. | 41   .0067568 |
           +---------------+
      .




      [/CODE]

      Comment


      • #4
        Thanks Nick - very helpful!

        Comment

        Working...
        X