Hello Statalists,
I am dealing with a real time data set with different data vinatges and I need to create a new variable that contains the last observation of each variable in the list (so I need the diagonal made up of the last ons of each var). Here the code:
g t = tq(1947q1) + _n -1
format t %tq
tsset t
local listaHPvintages " L65Q4 L66Q1 L66Q2 L66Q3 L66Q4 L67Q1 L67Q2 L67Q3 L67Q4 L68Q1 L68Q2 L68Q3 L68Q4 L69Q1 L69Q2 L69Q3 L69Q4 L70Q1 L70Q2 L70Q3 L70Q4 L71Q1 L71Q2 L71Q3 L71Q4 L72Q1 L72Q2 L72Q3 L72Q4 L73Q1 L73Q2 L73Q3 L73Q4 L74Q1 L74Q2 L74Q3 L74Q4 L75Q1 L75Q2 L75Q3 L75Q4 L76Q1 L76Q2 L76Q3 L76Q4 L77Q1 L77Q2 L77Q3 L77Q4 L78Q1 L78Q2 L78Q3 L78Q4 L79Q1 L79Q2 L79Q3 L79Q4 L80Q1 L80Q2 L80Q3 L80Q4 "
local start=tq(1965q4)
local finish=tq(2020q3)
g HPcycleGDP_realtime= .
forvalues i=`start'/`finish' {
foreach var in `listaHPvinatges' {
qui replace HPcycleGDP_realtime= HPcycle`var'[`i'] if t==`i'
}
}
Btw, each var contanis observations up to a certain t and then there are missing values.
Unfortunately the code doesn't work and HPcycleGDP_realtime remains an empty variable. Can does anyone help?
I am dealing with a real time data set with different data vinatges and I need to create a new variable that contains the last observation of each variable in the list (so I need the diagonal made up of the last ons of each var). Here the code:
g t = tq(1947q1) + _n -1
format t %tq
tsset t
local listaHPvintages " L65Q4 L66Q1 L66Q2 L66Q3 L66Q4 L67Q1 L67Q2 L67Q3 L67Q4 L68Q1 L68Q2 L68Q3 L68Q4 L69Q1 L69Q2 L69Q3 L69Q4 L70Q1 L70Q2 L70Q3 L70Q4 L71Q1 L71Q2 L71Q3 L71Q4 L72Q1 L72Q2 L72Q3 L72Q4 L73Q1 L73Q2 L73Q3 L73Q4 L74Q1 L74Q2 L74Q3 L74Q4 L75Q1 L75Q2 L75Q3 L75Q4 L76Q1 L76Q2 L76Q3 L76Q4 L77Q1 L77Q2 L77Q3 L77Q4 L78Q1 L78Q2 L78Q3 L78Q4 L79Q1 L79Q2 L79Q3 L79Q4 L80Q1 L80Q2 L80Q3 L80Q4 "
local start=tq(1965q4)
local finish=tq(2020q3)
g HPcycleGDP_realtime= .
forvalues i=`start'/`finish' {
foreach var in `listaHPvinatges' {
qui replace HPcycleGDP_realtime= HPcycle`var'[`i'] if t==`i'
}
}
Btw, each var contanis observations up to a certain t and then there are missing values.
Unfortunately the code doesn't work and HPcycleGDP_realtime remains an empty variable. Can does anyone help?
Comment