Announcement

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

  • Christina Gibson-Davis
    started a topic Creating two month intervals

    Creating two month intervals

    Hello,
    I would like to create a date variable that represent successive two month intervals - e.g., date = Jan/Feb 2011, March/April 2011, etc. I know that I can use the "qofd" command to generate quarters, but I do not see if/how that code could be modified to create two month intervals. My data are currently in month/year format.

    thank you,
    Christina


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float moyear
    612
    612
    612
    612
    613
    613
    613
    613
    614
    614
    614
    614
    615
    615
    615
    615
    616
    616
    616
    616
    617
    617
    617
    617
    618
    618
    618
    618
    619
    619
    619
    619
    620
    620
    620
    620
    621
    621
    621
    621
    622
    622
    622
    622
    623
    623
    623
    623
    624
    624
    624
    624
    625
    625
    625
    625
    626
    626
    626
    626
    627
    627
    627
    627
    628
    628
    628
    628
    629
    629
    629
    629
    630
    630
    630
    630
    631
    631
    631
    631
    632
    632
    632
    632
    633
    633
    633
    633
    634
    634
    634
    634
    635
    635
    635
    635
    636
    636
    636
    636
    end
    format %tm moyear
    ------------------ copy up to and including the previous line ------------------

  • Nick Cox
    replied
    You're welcome. (It's the same commands in either case.)

    Leave a comment:


  • Christina Gibson-Davis
    replied
    Thanks for the suggestion to look at stackoverflow. Clyde's commands also did the trick. Thanks.

    Leave a comment:


  • Nick Cox
    replied
    Discussed on Stack Overflow at https://stackoverflow.com/questions/...bimonthly-data

    You are right. qofd() and any other functions (not commands!) that take or give quarterly dates have no bearing on this. You just need to generate your own system and tsset or xtset accordingly. So, each two monthly period should be indexed by the first or the second month, according to taste or convention. If you want to see both months you will need to define value labels.

    That said, your data example shows monthly dates, so how you are going to get to two-monthly data is not exactly clear.

    Leave a comment:


  • Clyde Schechter
    replied
    There is nothing exactly analogous to quarterly dates or half-years for two-month intervals in Stata. The code below creates a new monthly variable that is assigned the same value for Jan and Feb 2011, Mar and Apr 2011, etc. The label it gets is that of the first month of the two-month interval. I think this will be suitable for most purposes.

    Code:
    gen int two_months = 2*floor(moyear/2)
    format two_months %tm

    Leave a comment:

Working...
X