Announcement

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

  • calculating lead values of an annual variable in a quarterly dataset

    Hi all,

    I have a dataset with 40 countries. Some variables are available on a quarterly basis while some variables are available on an annual basis.

    I have gdp forecasts annual data , I want to calculate GDP forecast at time t+1 , t+2, t+3 and t+4 (year t+1 , t+2 t+3 t+4)

    Sample dataset included below:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str97 location double(qdate year gdp_forecast_annual)
    "Australia" 41 1970 6.95457121381335
    "Australia" 42 1970 6.95457121381335
    "Australia" 43 1970 6.95457121381335
    "Australia" 44 1971 3.88811418259372
    "Australia" 45 1971 3.88811418259372
    "Australia" 46 1971 3.88811418259372
    "Australia" 47 1971 3.88811418259372
    "Australia" 48 1972 2.27675761035412
    "Australia" 49 1972 2.27675761035412
    "Australia" 50 1972 2.27675761035412
    "Australia" 51 1972 2.27675761035412
    "Australia" 52 1973 4.35304230982696
    "Australia" 53 1973 4.35304230982696
    "Australia" 54 1973 4.35304230982696
    "Australia" 55 1973 4.35304230982696
    "Australia" 56 1974 1.62215552938497
    "Australia" 57 1974 1.62215552938497
    "Australia" 58 1974 1.62215552938497
    "Australia" 59 1974 1.62215552938497
    "Australia" 60 1975 2.48283325135266
    "Australia" 61 1975 2.48283325135266
    "Australia" 62 1975 2.48283325135266
    "Australia" 63 1975 2.48283325135266
    "Australia" 64 1976 3.83800917313187
    "Australia" 65 1976 3.83800917313187
    "Australia" 66 1976 3.83800917313187
    "Australia" 67 1976 3.83800917313187
    "Australia" 68 1977 1.48596679362497
    "Australia" 69 1977 1.48596679362497
    "Australia" 70 1977 1.48596679362497
    end
    format %tq qdate
    I've tried many codes but none of them works. Could some one please help me with this?

    Thanks in advance.

  • #2
    I'm not sure I understand your question. You say you have quarterly data, but in the example shown, the variable gdp_forecast_annual is the same for every quarter within the same year. So it looks more like annual data that has been simply reproduced over quarters. If I do understand your question, you have "quarterly" data, and you want to compute leads of the gdp_forecast_annual at 1, 2, 3, and 4 years.
    Code:
    encode location, gen(country)
    xtset country qdate
    
    gen lead_1_year = L4.gdp_forecast_annual
    gen lead_2_year = L8.gdp_forecast_annual
    gen lead_3_year = L12.gdp_forecast_annual
    gen lead_4_year = L16.gdp_forecast_annual
    If this isn't what you want, please explain more clearly. Better still, post back with an brief example where you show the actual results you want.

    Comment

    Working...
    X