Announcement

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

  • How to change the order

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str20 x double y
    "a"   1
    "a" 1.1
    "a" 1.2
    "a" 1.3
    "a" 1.4
    "b" 1.5
    "b" 1.6
    "b" 1.7
    "c" 1.8
    "c" 1.9
    end

    tab y x

    | x
    y | a b c | Total
    -----------+---------------------------------+----------
    1 | 1 0 0 | 1
    1.1 | 1 0 0 | 1
    1.2 | 1 0 0 | 1
    1.3 | 1 0 0 | 1
    1.4 | 1 0 0 | 1
    1.5 | 0 1 0 | 1
    1.6 | 0 1 0 | 1
    1.7 | 0 1 0 | 1
    1.8 | 0 0 1 | 1
    1.9 | 0 0 1 | 1
    -----------+---------------------------------+----------
    Total | 5 3 2 | 10




    How to change the order of x in the tab command? because the display needs, you need to change the order of x and y from a b c to c b a or c a b in the tab x command

    the target result is as follows:

    | x
    y | c b a | Total
    -----------+---------------------------------+----------
    1 | 0 0 1 | 1
    1.1 | 0 0 1 | 1
    1.2 | 0 0 1 | 1
    1.3 | 0 0 1 | 1
    1.4 | 0 0 1 | 1
    1.5 | 0 1 0 | 1
    1.6 | 0 1 0 | 1
    1.7 | 0 1 0 | 1
    1.8 | 1 0 0 | 1
    1.9 | 1 0 0| 1
    -----------+---------------------------------+----------
    Total | 5 3 2 | 10




    levelsof x
    `"a"' `"b"' `"c"'

    but it needs the order
    `"c"' `"b"' `"a"'

    How to get the result of getting the corresponding target order in the above two commands(tab twoway & levelsof)

    Thank you very much!
Working...
X