Announcement

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

  • stata date format: how transform for example 736 into date format

    Hi everyone,

    I have a problem with date formatting in stata. I have a variable called "t", which is a float variable, in %tm format

    When I apply the summarize command to obtain my `min` and my `max`, I obtain a number instead of a date format value (in my case: 706 and 737).

    Code:
    summarize t
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
               t |  2,218,628    722.5383    9.279051        706        737
    Does anyone know how I can get this in date format please?
    Thank you in advance.

    Michael

  • #2
    Code:
    . di %tmMonth_CCYY 737
         June 2021
    
    . di %tmMonth_CCYY 706
     November 2018
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      you did not really supply enough info but if your variable "t" has a date format, then you can add the "format" option to your summarize command and you will see that the mean, the min and the max are formatted as desired; see
      Code:
      h summarize
      Last edited by Rich Goldstein; 04 May 2023, 05:54.

      Comment


      • #4
        Dear Maarten Buis: Thank you.

        Dear Rich Goldstein: You're right! Thank you so much for your suggestion. It works perfectly well.

        Best,

        Michael

        Comment

        Working...
        X