Announcement

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

  • How I can create serial number for category number stored in variable

    I have the following value
    1=1
    1=2
    1=3

    2=1
    2=2
    2=3
    2=4

    9=1
    9=2
    9=3
    9=4
    9=5
    9=6
    9=7
    9=8
    9=9
    9=10

  • #2
    This may help.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte whatever
    1
    1
    1
    2
    2
    2
    2
    9
    9
    9
    9
    9
    9
    9
    9
    9
    9
    end
    
    bysort whatever : gen wanted = _n
    
    list, sepby(whatever)
    
         +-------------------+
         | whatever   wanted |
         |-------------------|
      1. |        1        1 |
      2. |        1        2 |
      3. |        1        3 |
         |-------------------|
      4. |        2        1 |
      5. |        2        2 |
      6. |        2        3 |
      7. |        2        4 |
         |-------------------|
      8. |        9        1 |
      9. |        9        2 |
     10. |        9        3 |
     11. |        9        4 |
     12. |        9        5 |
     13. |        9        6 |
     14. |        9        7 |
     15. |        9        8 |
     16. |        9        9 |
     17. |        9       10 |
         +-------------------+

    Comment


    • #3
      Dear Nick Cox,

      Thank you so much for your kind assistance. Yousufzai

      Comment

      Working...
      X