I am Houda , I have the same problem of how to export results of the cros-correlations and the AR(1) coefficient, this is a part of my code
**********************************
clear*
set more off
cd "C:\Users\HOUDA\Desktop\New thesis\TMENA\ALGERIA\allsample"
log using "ALG.log", replace
use ALG_data.dta, clear
gen time=_n
tsset time
rename var2 RO /*real GDP*/
rename var3 NO /*nominal GDP*/
rename var4 NGC /*NOMINAL GOVERNMENT CONSUMPTION EXPENDITURES*/
rename var5 NPC /*nominal private consumption*/
rename var6 RGC /*real GOVERNMENT CONSUMPTION EXPENDITURES*/
rename var7 RPC /*real private consumption*/
rename var8 M /*nominal imports*/
rename var9 X /*nominal exports*/
rename var10 TB /*net exports= X-M*/
rename var11 RX /*Real exports*/
rename var12 RM /*Real imports*/
rename var13 RTB /*Real trade balance*/
rename var14 RINV /*Real investment*/
rename var15 Eng /*energy consumption*/
rename var16 RWR /*Real workers' remittances*/
rename var17 EXD /*external debts*/
gen tby=TB/NO
gen rtby=RTB/RO
gen lnRO=ln(RO)
gen lnRGC=ln(RGC)
gen lnRPC=ln(RPC)
gen lnRINV=ln(RINV)
gen lnEng=ln(Eng)
gen lnRWR=ln(RWR)
rename var1 Years
foreach var of varlist lnRO lnRGC lnRPC lnRINV lnEng lnRWR rtby{
twoway (line `var' Years, sort),title (ALGERIA) subtitle (`var') ytitle("`var'") xtitle("Years")
graph save Graph "C:\Users\HOUDA\Desktop\New thesis\TMENA\ALGERIA\allsample\pic\original_`var'.gph", replace
tsfilter hp hp`var' = `var',smooth(100) trend(hp`var'_tr)
*********************Volatility, peristence and correlations of the cyclical component***********
xcorr hplnRO hp`var', lags(1) table
egen hp`var'_sd = sd(100*hp`var')
gen hp`var'_relsd=hp`var'_sd/hplnRO_sd
corrgram hp`var', lags(1)
egen hp`var'_tr_sd = sd(100*hp`var'_tr)
gen hp`var'_tr_relsd=hp`var'_tr_sd/hplnRO_tr_sd /*the contribution of the trend volatility to the gdp volatility*/
gen hp`var'_tr_relsdd=hplnRO_tr_sd/hp`var'_tr_sd /*the contribution of the trend volatility of GDP to the variables volatility-reverse of the ratio above*/
}
************subperiods analysis****************
gen period1=(time<=31)
gen period2=(time>31)
************gross variables analysis***********************
foreach var of varlist lnRO lnRGC lnRPC lnRINV lnEng lnRWR rtby { /*Identification of the variables cyclical component obtained from the first part */
forvalues i = 1/2 { /*we keep the denomenation {`var' for gross variables */
gen `var'`i'=`var' if period`i'==1
}
}
foreach var of varlist lnRO lnRGC lnRPC lnRINV lnEng lnRWR rtby { /*growth rate computing for gross variables */
forvalues i = 1/2 {
************growth series of gross variables********
gen `var'`i'_ret=`var'`i'[_n-1] if period`i'==1
gen GROWTH_`var'`i'= (`var'`i'-`var'`i'_ret) if period`i'==1
egen GROWTH_`var'`i'_sd = sd(100*GROWTH_`var'`i') if period`i'==1
gen GROWTH_`var'`i'_relsd=GROWTH_`var'`i'_sd/GROWTH_lnRO`i'_sd if period`i'==1
twoway (line `var'`i' Years, sort),title (ALGERIA) subtitle (`var'`i') ytitle("`var'`i'") xtitle("Years")
graph save Graph "C:\Users\HOUDA\Desktop\New thesis\TMENA\ALGERIA\allsample\pic`i'\original_`var'`i'.gph", replace
}
}
save ALG.dta, replace
log close
************************************************
So how can I exports the results of xcorr and corrgram?, I need your help because I am working on 19 countries, and going back to the log file to copy results variable by variable take a lot of time.
thanks