Announcement

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

  • Efficient lags? Is copy and paste better?

    I am trying to link the volume sold on a service to the price of it. However, the timing differs as the service gets paid months in advance. Consequently, a lag is required.

    However, as my data on volume starts on Januar 2005 (first line), I need price data from 2004 (e.g. October 2004 for price and January 2005 for volume in case of a 3 months time lag).

    I am thinking about creating a new variable (call it 3mLag or so), where I simply move the pricing data by 3 lines (copy paste) while putting in the missing data for 2004.

    Is there probably a faster way that may help as my procedure is only simple in case of a small number of lags to be implemented?



  • #2
    You never want to copy/paste: It's non-repeatable, error-prone, slow, etc. It has its purposes, I admit, but professional data analysis is not a good place to use it.

    Exactly how to solve your problem, though, depends on the structure of your data, which is not apparent from your description. Please check out the FAQ regarding the use of -dataex- to post sample data, and then we can almost certainly offer you a good answer.

    I'm guessing that the use of explicit subscripting (-search subscripting-) and possibly -tsset- will be relevant, but without further information, it's hard to tell.

    Comment


    • #3
      Adding to Mike Lacy's excellent advice, do read -help tsvarlist- to learn about Stata's lag operator, which may prove very useful here.

      Comment


      • #4
        Thanks, I am going to check out the help section.

        Comment

        Working...
        X