Announcement

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

  • -format visit_date %tdDD/NN/CCYY- in Stata 18

    I just updated Stata 17 to 18. The variable visit_date in my dataset used to show 19/03/2013 now turned out to be 19mar2013, even after -format visit_date %tdDD/NN/CCYY- in Stata 18. The new release seemed did not mention any change to date variables. What was I missing?

  • #2
    That shouldn't be happening. Some new date-calculation functions have been added to Stata, but the basics of date and datetime variable, and their display formats, have not changed in Stata 18. Can you use the -dataex- command and post a data example that has this problem. Then show the exact code you used and show what Stata did in response. If you're doing something wrong, those details would be important to figure out what.

    In both versions 17 and 18, -dataex- is already part of your official Stata installation. Run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.



    Comment


    • #3
      Thank you, Clyde!

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input int(id visit_date) float ams
      1001 19436        .
      1001 19527        8
      1001 19569 7.368421
      1001 19695 4.756757
      1001 19793 5.098039
      1001 19891 5.507692
      1001 20108  5.34375
      1001 20290 5.057377
      1001 20472 4.871622
      end
      format %tdDD/NN/CCYY visit_date
      The visit_date displays as what I wanted 19/03/2013 when -list id visit_date ams-

      However, -browse- in Stata 18 on my machine shows 19mar2013 ...

      I wonder whether it's my Data Editor Window is not set up appropriately. It would be helpful to see if it's the case on another machine. Thank you very much.

      Comment


      • #4
        I can't reproduce your problem with the most recently updated version of Stata 18 (13jul2023). The listed output matches to what I see in the data browser after applying each format to -visit_date-.

        Code:
        format %td visit_date
        list visit_date
        
        format %tdDD/NN/CCYY visit_date
        list visit_date
        Result

        Code:
        . list visit_date
        
             +-----------+
             | visit_d~e |
             |-----------|
          1. | 19mar2013 |
          2. | 18jun2013 |
          3. | 30jul2013 |
          4. | 03dec2013 |
          5. | 11mar2014 |
             |-----------|
          6. | 17jun2014 |
          7. | 20jan2015 |
          8. | 21jul2015 |
          9. | 19jan2016 |
             +-----------+
        
        . list visit_date
        
             +------------+
             | visit_date |
             |------------|
          1. | 19/03/2013 |
          2. | 18/06/2013 |
          3. | 30/07/2013 |
          4. | 03/12/2013 |
          5. | 11/03/2014 |
             |------------|
          6. | 17/06/2014 |
          7. | 20/01/2015 |
          8. | 21/07/2015 |
          9. | 19/01/2016 |
             +------------+

        Comment


        • #5
          Lisa NingLi, this was fixed in the 15may2023 update. Type update all in Stata to apply the recent updates.

          Comment


          • #6
            Thanks, James. The dates display appropriately after -update all-.

            Comment

            Working...
            X