Announcement

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

  • Tag observation based on its histogram bins

    Hi Stata Gurus,

    Need some help on how to Tag dataset 's observations based on its histogram bin number(1-9)

    Code:
    . webuse auto
    (1978 Automobile Data)
    
    . histogram price, frequency addlabel
    (bin=8, start=3291, width=1576,875)
    histo.JPG

    I went little further

    Code:
    . frame create histogram
    . frame histogram:{
    . serset use
    . gen bin = _n
    . list
    
         +--------------------------------------+
         | __000009   __00000A   __00000B   bin |
         |--------------------------------------|
      1. |       35          0    4.079,4     1 |
      2. |       21          0    5.656,3     2 |
      3. |        4          0    7.233,2     3 |
      4. |        2          0    8.810,1     4 |
      5. |        4          0     10.387     5 |
         |--------------------------------------|
      6. |        3          0     11.964     6 |
      7. |        3          0     13.541     7 |
      8. |        2          0     15.118     8 |
      9. |        .          0      3.291     9 |
         +--------------------------------------+
    . }
    and tried , also, twoway__histogram_gen, but with no success.

    thks, Luis (Stata MP 16.1)
Working...
X