Announcement

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

  • How do I sort my observations by variables "start date" which shows the date and time?

    Hi, I have a variable "startdate" which shoes date and time for an observation in the following format - (Month/Date/Year) time

    startdate enddate
    7/9/2024 1:13. 7/9/2024 1:24
    7/9/2024 1:28 7/9/2024 2:01
    7/9/2024 1:30 7/10/2024 12:24
    7/9/2024 1:39 7/9/2024 1:52
    7/9/2024 1:46. 7/9/2024 2:00
    7/9/2024 1:59 7/9/2024 2:07

    NOTE: startdate and enddate are two separate variables in my dataset.

    How do I sort the data such that the observations go from the latest to the most recent in terms of time?

    Thanks for your help!
    Last edited by anisha arya; 03 Aug 2024, 05:54.

  • #2
    Are these string or numeric variables? Please use dataex to make that and other details clear. https://www.statalist.org/forums/help#stata

    Comment


    • #3
      Hi Nick,

      Sorry about that very new to the platform. These are string variables.

      Thanks
      Anisha

      Comment


      • #4
        Code:
        h datetime

        Comment


        • #5
          As said, please use dataex.

          Code:
          dataex startdate enddate

          Comment

          Working...
          X