Hello Everybody,
Once again needing help.
I will like some help with a loop over varsoc.
The programme I´ve iobtained comes form here:
http://www.stata.com/statalist/archi.../msg00264.html
I have adapted it. I have set of time series running over 45 years for 26 countries in 14 variables.
I want a matrix that summarizes all the varsocs, runned through the contires and variables.This should give me a matrix of 14*26*5 (number of lags used 0/4)=1820
My code is:
set matsize 2000
levelsof Cou, local(levels)
foreach l of local levels {
foreach var of varlist Y Yx D Px PX e M m X x PM R Kp KP {
varsoc `var' if Cou == `l'
matrix A = r(stats)
if `l' > 1 {
matrix C = C \ A
}
else {
matrix C = A
}
}
}
It works perfectly for all stimates and gives me a C matrix that summarizes all the varsocs. however it jumps the first 13 variables from Y to Kp of the first country, So instead of having a matrrix of 1820 is of 1755.
My guess is that the error is in here
if `l' > 1 {
matrix C = C \ A
}
else {
matrix C = A
}
I´ve tried, changing it to :
if `l' >= 1 {
matrix C = C \ A
}
or other things but it doesn´t work or loops over and over....
Please help!
Thankyou very much.
Manuel.

Comment