Announcement

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

  • Get dates in order

    Hi all,

    I have a bunch of dates in a wide version of my data called datecall1 datecall2.....so on and so forth. However, they aren't in order. For instance datecall1 might be "05may2020" and datecall2 may be "05may2018" and datecall3 may be "05may2019." If I want to rework these so that they are always in ascending order so datecall1 would be "05may2018" and datecall2 would be "05may2019" and datecall3 would be"05may2020" is there a way to do this?
    Thanks!

  • #2
    Nick Cox's rowsort command, available at http://www.stata-journal.com/software/sj9-1, does this.

    Comment


    • #3
      You've been here long enough to know to post a data example. Please, do post one using dataex. The solution might become more clear once we can see what the data really look like

      Comment


      • #4
        Sorry, data is super private so I didn't want to risk sharing any example of it! I will try rowsort, thank you!!

        Comment


        • #5
          Data privacy is not a reason to not show examples. For nearly all applications, the actual values of the data are unimportant, it is the organization that counts. So if you can't show the real thing, make up a new data set that is organized exactly like the real one, but with made-up values. Then use -dataex- to show that.

          Comment


          • #6
            Dear Lindsey, you have been here for some time now. Section 12.2 of the FAQ clearly lays out instructions (my highlights).

            12.2 What to say about your data

            We can understand your dataset only to the extent that you explain it clearly.

            The best way to explain it is to show an example.
            The community-contributed command dataex makes it easy to give simple example datasets in postings. It was written to support Statalist and its use is strongly recommended. Usually a copy of 20 or so observations from your dataset is enough to show your problem. See help dataex for details.

            As from Stata 15.1 (and 14.2 from 19 December 2017), dataex is included with the official Stata distribution. Users of Stata 15 (or 14) must update to benefit from this. Users of Stata 16 or 17 need not do anything: dataex is already part of your installation.

            Users of earlier versions of Stata must install dataex from SSC before they can use it. Type ssc install dataex in your Stata.

            The merits of dataex are that we see your data as you do in your Stata. We see whether variables are numeric or string, whether you have value labels defined and what is a consequence of a particular display format. This is especially important if you have date variables. We can copy and paste easily into our own Stata to work with your data.

            If your dataset is confidential, then provide a fake example instead.

            The second best way to explain your situation is to use one of Stata's own datasets and adapt it to your problem. Examples are the auto data and the Grunfeld data (a simple panel dataset). That may be more work for you and you may not find an analog of your problem with such a dataset.

            The worst way to explain your situation is to describe your data vaguely without a concrete example. Note that it doesn't help us much even to be given your variable names. Often that leaves unclear both your data structure and whether variables are numeric or string or their exact contents. If you explain only vaguely, quick answers to your question, or even any answers at all, are less likely.

            Comment

            Working...
            X