Announcement

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

  • Sort a time variable

    Hello Stata people,

    I'm using Stata version 13.1, I'm working with this small data currently:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int Year float(Savings Financial_Savings)
    2024 18.206  9.039
    2023 16.982  6.929
    2022 16.861  5.573
    2021 19.072  7.677
    2020 20.432 10.424
    2019 14.617  4.088
    2018 13.865  3.529
    2017 14.013  4.028
    2016 13.794   4.33
    2015 13.983  4.698
    2014 14.523  5.213
    2013 14.208  4.703
    2012 15.557   6.12
    2011 15.429  5.891
    2010 15.776  6.522
    2009 16.111  6.969
    2008 14.634  4.075
    2007 14.769  4.255
    2006 14.339  4.042
    2005 13.975  3.804
    2004 14.695  4.361
    2003 14.603  5.025
    2002 15.097  5.821
    2001  14.01  4.856
    2000 13.331  4.639
    1999 13.296  4.784
    1998 13.576  4.491
    1997 14.388  5.618
    1996 13.394  4.552
    1995 14.163  5.244
    1994 13.572  4.567
    1993 14.545  6.144
    1992 14.138  5.042
    1991 13.097  2.874
    1990 12.565  1.724
    1989 11.377  -.215
    1988 11.242   .368
    1987 11.245   .177
    1986 12.529  2.003
    1985 13.263  3.055
    1984 14.151  3.119
    1983 15.576  4.089
    1982 16.231  4.153
    1981 17.326  4.214
    1980 17.873  3.121
    1979 18.552  4.148
    1978 20.828  6.477
    1977 19.309   5.43
    1976 19.276  5.075
    1975 21.476  7.191
    1974 20.543  4.288
    1973  20.25  4.267
    1972 19.876  4.356
    1971 19.519  4.982
    1970 19.677  4.941
    1969 17.536  2.544
    1968 18.795  3.847
    1967 18.617  4.059
    1966 18.125  3.146
    1965 17.904  3.513
    1964  17.14  3.433
    1963 17.235  4.775
    1962 17.731  5.753
    1961 15.409  3.629
    1960 16.176  3.966
    1959 14.007  2.114
    1958 15.238  2.982
    1957 14.572  2.523
    1956 13.544  2.875
    1955 15.933  5.084
    1954 14.792  4.471
    1953 12.755  3.408
    1952 14.491  4.822
    1951 13.853  4.435
    1950 14.516  6.527
    end
    The goal is that I want to sort the "Year" variable from the oldesy year to the newest year, in order to be able to draw a time graph afyer that.

    Any help with that?

    With many thanks!


  • #2
    Code:
    sort Year
    it would be good to get feedback on your last two threads.

    Comment


    • #3
      Nick Cox Thanks, that worked. I'm sorrt if the solution seemed too obvious and too simple to ask, but sometimes, one forgets the simplest rules and needs to ask.
      Again, thanks for the help!

      Comment


      • #4
        Note that a prior sort isn't essential: as documented at (e.g.)

        Code:
        help connect options
        a sort option can be specified in the graph twoway command.

        Comment


        • #5
          Nick Cox I understand Thanks very much for the clarification.

          Comment

          Working...
          X