Announcement

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

  • help formating date

    Hi,

    I have been struggling with getting the right format on dates for a while now. I have downloaded everything from freduse in quarterly data, but somehow when I try to get the variable daten to show the date as YQ it messes up.

    Every observation is quarterly, but somehow it was originally stored as daily format giving my the values for example:

    daten
    01apr1947 01jul1947
    01oct1947

    And so on.

    When i try to change the format using this
    Code:
     format %tq daten
    it changes to:

    daten
    0795q3
    0818q2
    0841q2

    The first one in daily format is readable and possible to work with, the problem however is that I need to merge this statafile to another that has the formating in YQ, and i am not able to merge those two files. Does anyone know what I can do to fix this?
    Attached Files

  • #2
    As you've discovered, that's wrong -- because changing a display format never changes the underlying values; it just changes how those values are displayed.

    You're asked not to post .dta attachments, but conversely typing this code and studying the results gives you a self-contained example. Please see https://www.statalist.org/forums/help#stata

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float problem
    -4658
    -4567
    -4475
    end
    
    . format problem %td
    
    . list
    
         +-----------+
         |   problem |
         |-----------|
      1. | 01apr1947 |
      2. | 01jul1947 |
      3. | 01oct1947 |
         +-----------+
    
    . format problem %tq
    
    . list
    
         +---------+
         | problem |
         |---------|
      1. |  0795q3 |
      2. |  0818q2 |
      3. |  0841q2 |
         +---------+
    
    . gen solution = qofd(problem)
    
    . format solution %tq
    
    . list
    
         +--------------------+
         | problem   solution |
         |--------------------|
      1. |  0795q3     1947q2 |
      2. |  0818q2     1947q3 |
      3. |  0841q2     1947q4 |
         +--------------------+
    
    .
    For a fuller explanation, see https://www.stata-journal.com/articl...article=dm0067

    Comment


    • #3
      This worked! You really made my day! Thanks a lot!

      Comment

      Working...
      X