loop and rename
Posted: Thu May 23, 2013 8:26 am
I have estimated the Impulse response functions for 27 countries with a loop on a VAR and saved them in matrix var_irf{!i} for !i= 1 to 27
Now I want to transform the matrix in a group of series and rename each series so that the first index in IRF_1_1 stands for country 1 and the second for the response of the first variable to the first shock; the second index goes from 1 to pxp where p is the number of variables in the VAR. I have 4 variables so and the second index goers from 1 to 16
I have attached below the program
pagecreate(page=IRF) u 1 10
for !i =1 to 27
copy crossection_EU\var_irf{!i} IRF\var_irf{!i}
mtos(var_irf{!i}, group{!i})
next
for !i =1 to 9
rename ser0{!i} ser{!i}
next
for !i =1 to 27
for !j =1 to @columns(group{!i})
rename ser{!j} IRF_{!i}_{!j}
next
next
The problem is that it renames the series only for country 1 ; for country 2 I got the following error message: SER1 is not defined in "RENAME SER 1IRF_2_1"
I understand that the problem is that the first series in group 2 does not start with SER1 but with SER17 but I m' not able to change this in the programme
I would appreciate any help for this
Regards
Alfonso
Now I want to transform the matrix in a group of series and rename each series so that the first index in IRF_1_1 stands for country 1 and the second for the response of the first variable to the first shock; the second index goes from 1 to pxp where p is the number of variables in the VAR. I have 4 variables so and the second index goers from 1 to 16
I have attached below the program
pagecreate(page=IRF) u 1 10
for !i =1 to 27
copy crossection_EU\var_irf{!i} IRF\var_irf{!i}
mtos(var_irf{!i}, group{!i})
next
for !i =1 to 9
rename ser0{!i} ser{!i}
next
for !i =1 to 27
for !j =1 to @columns(group{!i})
rename ser{!j} IRF_{!i}_{!j}
next
next
The problem is that it renames the series only for country 1 ; for country 2 I got the following error message: SER1 is not defined in "RENAME SER 1IRF_2_1"
I understand that the problem is that the first series in group 2 does not start with SER1 but with SER17 but I m' not able to change this in the programme
I would appreciate any help for this
Regards
Alfonso