Announcement

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

  • This should be quick :)

    I have a large data set data from the field of education which was coded by grade. The Kindergarten was coded as K, which I changed to 0 so I could treat this data as ordinal. In Stata, when I sort by grade, I get the following and can't seem to get my data in the 'right' order which would be 0-12. Thanks in advance. If it helps, the data are red so I think it still thinks it is string. Also, I apologize I am new to all this.


    year Freq. Percent Cum.

    0 85,622 13.02 13.02
    1 84,395 12.83 25.85
    10 23,519 3.58 29.42
    11 15,788 2.40 31.82
    12 15,196 2.31 34.13
    2 87,471 13.30 47.43
    3 86,274 13.12 60.54
    4 71,705 10.90 71.44
    5 51,963 7.90 79.34
    6 37,854 5.75 85.10
    7 32,982 5.01 90.11
    8 28,870 4.39 94.50
    9 36,176 5.50 100.00

    Total 657,815 100.00

    I appreciate the help.
    Brynne

  • #2
    Your data is being sorted alphanumerically because your grade variable was interpreted by stata as a string of characters. You need to convert grade to a number. Something like this should work.

    Code:
    gen num_year = real(year)
    Last edited by Daniel Schaefer; 24 Oct 2022, 18:00. Reason: more descriptive language

    Comment


    • #3
      Thanks, worked like a charm.

      Comment


      • #4
        No problem. Welcome to the forum!

        Comment

        Working...
        X