Announcement

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

  • Combination of quarters belonging to different year into one year

    Hi all,

    I have a dataset with monthly observations, the subset is as follows. However, here in the example, it shows the numbers instead of the actual dates my data carries.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float firm_id int(date Year articles1)
    12 17167 2007 0
    12 17198 2007 0
    12 17226 2007 0
    12 17257 2007 0
    12 17287 2007 0
    12 17318 2007 0
    12 17348 2007 0
    12 17379 2007 0
    12 17410 2007 0
    12 17440 2007 0
    12 17471 2007 0
    12 17501 2007 0
    12 17532 2008 0
    12 17563 2008 0
    12 17592 2008 0
    12 17623 2008 0
    12 17653 2008 0
    12 17684 2008 0
    12 17714 2008 0
    12 17745 2008 0
    12 17776 2008 0
    12 17806 2008 0
    12 17837 2008 0
    12 17867 2008 0
    12 17898 2009 0
    12 17929 2009 0
    12 17957 2009 0
    12 17988 2009 0
    12 18018 2009 0
    12 18049 2009 0
    12 18079 2009 0
    12 18110 2009 0
    12 18141 2009 0
    12 18171 2009 0
    12 18202 2009 0
    12 18232 2009 0
    12 18263 2010 0
    12 18294 2010 0
    12 18322 2010 0
    12 18353 2010 0
    12 18383 2010 0
    12 18414 2010 0
    12 18444 2010 0
    12 18475 2010 0
    12 18506 2010 0
    12 18536 2010 0
    12 18567 2010 0
    12 18597 2010 0
    12 18628 2011 0
    12 18659 2011 0
    12 18687 2011 0
    12 18718 2011 0
    12 18748 2011 0
    12 18779 2011 0
    12 18809 2011 0
    12 18840 2011 0
    12 18871 2011 0
    12 18901 2011 0
    12 18932 2011 0
    12 18962 2011 0
    12 18993 2012 0
    12 19024 2012 0
    12 19053 2012 0
    12 19084 2012 0
    12 19114 2012 0
    12 19145 2012 0
    12 19175 2012 0
    12 19206 2012 0
    12 19237 2012 0
    12 19267 2012 3
    12 19298 2012 0
    12 19328 2012 0
    12 19359 2013 0
    12 19390 2013 0
    12 19418 2013 0
    12 19449 2013 0
    12 19479 2013 0
    12 19510 2013 0
    12 19540 2013 0
    12 19571 2013 0
    12 19602 2013 0
    12 19632 2013 0
    12 19663 2013 0
    12 19693 2013 0
    12 19724 2014 0
    12 19755 2014 0
    12 19783 2014 0
    12 19814 2014 0
    12 19844 2014 0
    12 19875 2014 0
    12 19905 2014 0
    12 19936 2014 0
    12 19967 2014 0
    12 19997 2014 0
    12 20028 2014 0
    12 20058 2014 0
    12 20089 2015 0
    12 20120 2015 0
    12 20148 2015 0
    12 20179 2015 0
    end
    format %tdCY-N-D date


    I can convert it into quarterly observation by the following command-

    gen qdate=qofd(date)
    format qdate %tq

    My problem is I need to convert these quarterly observations into a year that consists of April- March.
    For instance , Yr 2006= 2005q2 + 2005q3+2005q4+2006q1 and so on..

    Kindly help me to locate the command for this.

    Thanks,
    Anita

  • #2
    See my paper on “Species of origin” in Stata Journal 15(2) for details on non-calendar years.

    Comment


    • #3
      Nick Cox, Hi,

      I am really grateful for the comments.It worked.
      I used the following command.
      generate ncy = cond(quarter(dofq(qdate)) >= 2, Year, Year - 1)

      Thanks a lot.
      Regards,
      Anita

      Comment

      Working...
      X