Announcement

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

  • How to convert monthly dates into quarterly dates

    Hi statalist forum, I need your help with a small problem. I have a variable in stata's monthly date format, and I need to create a new variable which contains the same dates converted into quarterly dates. Thanks very much!

  • #2
    Code:
    help datetime
    Code:
    . clear
    
    . set obs 1
    Number of observations (_N) was 0, now 1.
    
    . gen please_give_an_example = ym(2023, 2)
    
    . format please_give_an_example %tm
    
    . gen wanted = qofd(dofm(please_give_an_example))
    
    . format wanted %tq
    
    . l
    
         +-------------------+
         | please~e   wanted |
         |-------------------|
      1. |   2023m2   2023q1 |
         +-------------------+

    Comment

    Working...
    X