Announcement

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

  • Date is being displayed in SIF despite applying %td format

    I have a variable test:

    Code:
                  storage   display    value
    variable name   type    format     label      variable label
    -------------------------------------------------------------------------------------------------------------------
    test            double  %tc                
    
    
    . tab test
    
      Date/time |
      submitted |      Freq.     Percent        Cum.
    ------------+-----------------------------------
      30jul20.. |          1        .6       
      30jul20.. |          1        0.44
    I want to convert it only to a date format (no time). I tried -format test %td- as the datetime helpfile seems to suggest, but then it gets converted to SIF despite having a %td format:

    Code:
    . format test %td
    
    . desc test
    
                  storage   display    value
    variable name   type    format     label      variable label
    -------------------------------------------------------------------------------------------------------------------
    test            double  %td                
    
    . tab test
    
      Date/time |
      submitted |      Freq.     Percent        Cum.
    ------------+-----------------------------------
       1.85e+12 |          1        0.6       
       1.85e+12 |          1        0.44
    What am I doing wrong? Thanks
    Last edited by Kosmas Yeo; 04 Sep 2018, 09:01.

  • #2
    See SIF to SIF conversion section of the help file (help datetime).
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      I tried -format test %td- as the datetime helpfile seems to suggest
      It cannot be over-emphasized, nor too often repeated, that changing the display format of a datetime variable (as you did) does not change it from clock to daily, or daily to monthly, etc. That requires a conversion function, such as -dofc()-, and then the application of the appropriate new display format.

      More generally, the -format- command never changes the values of a variable, only how they are displayed in some commands. Daily date and clock datetime variables are different animals, and displaying either as the other just gives you gibberish.

      Comment


      • #4
        https://www.stata-journal.com/sjpdf....iclenum=dm0067 sings Clyde's song at greater length.

        Comment

        Working...
        X