Announcement

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

  • What is %td.. ?

    Dear all,

    Hi, I have a variable InceptionDate. When I run "d InceptionDate", I get

    storage display value
    variable name type format label variable label
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    InceptionDate~S int %td.. Inception Date

    I thought InceptionDate was an integer variable (e.g., 19990803), which I was intending to use to generate a %td variable. But the display format "%td.." appears to say it's already %td variable. But then again, it's not "%td". I'm not sure what to make of it.
    I'd appreciate your help in how to interpret this or how to generate a %td variable. Thank you very much!

    Best,
    John

  • #2
    In Stata, dates are usually stored as integers, with 01jan1960 as zero. Your example date would be 14459. When you change the display format of that integer to %td, it merely alters how that integer looks to you. For instance,

    Code:
    . di td(02may2015)
    20210
    
    . di %td 20210
    02may2015
    
    . di %tdM-D-Y 20210
          May-02-15
    Last edited by Dimitriy V. Masterov; 02 May 2015, 20:40.

    Comment


    • #3
      Dear Dimitriy,
      Thanks for your comment. I am aware of the display variations of %td, but I was not able to find what "%td.." means, which is why I'm not sure if that actually is a date variable. I'd appreciate your thoughts.
      Thank you!

      Best,
      John

      Comment


      • #4
        I guess I did not connect all the dots. That's just Stata shorthand for a custom %td format that is too long to fit in the output of des:

        Code:
        . set obs 10
        number of observations (_N) was 0, now 10
        
        . gen date = 10000+_n
        
        . format date %td
        
        . clonevar date2=date
        
        . format date2 %tdCCYYNNDD
        
        . des
        
        Contains data
          obs:            10                          
         vars:             2                          
         size:            80                          
        --------------------------------------------------------------------------------------------------------------
                      storage   display    value
        variable name   type    format     label      variable label
        --------------------------------------------------------------------------------------------------------------
        date            float   %td                   
        date2           float   %td..                 
        --------------------------------------------------------------------------------------------------------------
        Sorted by: 
             Note: Dataset has changed since last saved.
        
        . list, clean noobs
        
                 date      date2  
            20may1987   19870520  
            21may1987   19870521  
            22may1987   19870522  
            23may1987   19870523  
            24may1987   19870524  
            25may1987   19870525  
            26may1987   19870526  
            27may1987   19870527  
            28may1987   19870528  
            29may1987   19870529
        Last edited by Dimitriy V. Masterov; 02 May 2015, 21:10.

        Comment


        • #5
          Dimitri has provided a thorough explanation.

          I just wish to underline that John is supposed to use the - date() - function to create a date variable before editing the display of the date.

          Best,

          Marcos
          Best regards,

          Marcos

          Comment


          • #6
            I am not sure that the -date()- advice right. I think John has a td variable formatted to look like an integer, mostly likely as %tdCCYYNNDD. The easiest way to learn what the format is to use the -varmanage- command to open the Variable Manager. That would give the full format, unlike -des-.

            Comment

            Working...
            X