Dear all,
I have program which is supposed to loop through a really big for loop (start and end highlighted in color and bold script) using in each step new input to open a new workfile, computing results and saving the results at the end of the step in predetermined folders, after that the loop would be expected to go into the next step. EVIEWS stops after producing correct results in the first step, giving me as the last log-file row the value which is defined as the second argument of the loop (%replace2), i.e. the string containing the values, which the changing loop variable (%replace) is supposed to take on. Relevant code extracts are below.
Is there any way to make the loop working? Many thanks in advance
wfopen(page=Data) "M:\Risk Analysis\Workstreams\22_Mutual Funds\5_Risk_indicators\01_MMF\MMF_return_RD_weekly.csv" names=(fund, date, return)
pageunstack(page=FundSeries) fund date @ return
delete fund
scalar loopchoice = 1
string labelloopchoice = "Choice whether to loop over set of endogenous (1) or reduced sets of exogenous variables (2)"
string optionloopchoice = "1 2"
@uidialog("Caption", "Define Settings", "Radio", loopchoice, labelloopchoice, optionloopchoice)
!countreplace =1
if loopchoice = 1 then
%replace = "%modelvar"
%replace2 = "2mom 3per 3perasy 5per 5perasy '9per"
%replace3 = "exores1 exores2 exores3 exores4 exores5 exores6 exores7 exores8 exores9 exores10"
else
%replace = "%endvarexcl"
%replace2 = "eonia credit_risk eur_floating_rate int_rate_risk__usd_ liq_risk__usd_ gbp_eur jpy_eur usd_eur lowintproxy MATURITY_RISK_IN_BANK_DE"
%replace3 = "exores1 exores2 exores3 exores4 exores5 exores6 exores7 exores8 exores9"
endif
!loopchoice = loopchoice
for {%replace} {%replace2}
if !countreplace >1 then
wfopen(page=Data) "M:\Risk Analysis\Workstreams\22_Mutual Funds\5_Risk_indicators\01_MMF\MMF_return_RD_weekly.csv" names=(fund, date, return)
pageunstack(page=FundSeries) fund date @ return
delete fund
endif
if !loopchoice = 1 then
if %modelvar = "3per" or %modelvar = "3perasy" then
scalar criteria = 3
if %modelvar = "3per" then
%endomom = "medianwins per90wins per10wins"
else
%endomom = "medianwins per99wins per90wins"
endif
else
if %modelvar = "5per" or %modelvar = "5perasy" then
scalar criteria = 5
if %modelvar = "5per" then
%endomom = "medianwins per99wins per75wins per25wins per01wins"
else
%endomom = "medianwins per99wins per95wins per90wins per75wins"
endif
else
if %modelvar = "9per" then
scalar criteria = 9
%endomom = "medianwins per99wins per95wins per90wins per75wins per25wins per10wins per05wins per01wins"
else
if %modelvar = "2mom" then
scalar criteria = 2
%endomom = "meanwins stdwins"
endif
endif
endif
endif
%exvarset = "eonia credit_risk eur_floating_rate int_rate_risk__usd_ liq_risk__usd_ gbp_eur jpy_eur usd_eur lowintproxy MATURITY_RISK_IN_BANK_DE"
%saveloc = "M:\Risk Analysis\Workstreams\22_Mutual Funds\5_Risk_indicators\01_MMF\results\9 exog var\corr\" +%modelvar+"\MMF_indicator_output"
%saveloc2 = "M:\Risk Analysis\Workstreams\22_Mutual Funds\5_Risk_indicators\01_MMF\results\9 exog var\corr\" +%modelvar+"\MMF_indicator_fundlistnamechange"
%saveloc3 = "M:\Risk Analysis\Workstreams\22_Mutual Funds\5_Risk_indicators\01_MMF\results\9 exog var\corr\" +%modelvar+"\log"
%savefile = "M:\Risk Analysis\Workstreams\22_Mutual Funds\5_Risk_indicators\01_MMF\results\10 exog var\corr\percentiles\" +%modelvar+"\MMF_sysrisk_ind_weekly_a_lag_3"
else
scalar criteria = 4
%endomom = "meanwins stdwins skewwins kurtosiswins"
%exvarset = @wdrop("eonia credit_risk eur_floating_rate int_rate_risk__usd_ liq_risk__usd_ gbp_eur jpy_eur usd_eur lowintproxy MATURITY_RISK_IN_BANK_DE", %endvarexcl)
%saveloc = "M:\Risk Analysis\Workstreams\22_Mutual Funds\5_Risk_indicators\01_MMF\results\9 exog var\corr\" +%endvarexcl+"\MMF_indicator_output"
%saveloc2 = "M:\Risk Analysis\Workstreams\22_Mutual Funds\5_Risk_indicators\01_MMF\results\9 exog var\corr\" +%endvarexcl+"\MMF_indicator_fundlistnamechange"
%saveloc3 = "M:\Risk Analysis\Workstreams\22_Mutual Funds\5_Risk_indicators\01_MMF\results\9 exog var\corr\" +%endvarexcl+"\log"
%savefile = "M:\Risk Analysis\Workstreams\22_Mutual Funds\5_Risk_indicators\01_MMF\results\9 exog var\corr\" +%endvarexcl+"\MMF_sysrisk_ind_weekly_a_lag_3"
endif
...... Code goes on.... till...
pagesave(type=excel,mode=overwrite) %saveloc2
wfsave %savefile
logsave %saveloc3
!countreplace = !countreplace + 1
next
Replacement in for loop works on only in first step
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Replacement in for loop works on only in first step
I don't think you can define a for loop control variable in braces.
Re: Replacement in for loop works on only in first step
So there is no chance to have a for loop with flexible names for the step variable and flexible lists through which the step variable runs?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Replacement in for loop works on only in first step
I can see no reason, whatsoever, for flexibility in the step variable. But, yes, you can absolutely change the list that it loops through.
Re: Replacement in for loop works on only in first step
I wanted to avoid a if structure implying replication of the same code in both branches, as I would use the flexible step variable for various loops of VAR models using different sets of inputs for endogenous and exogenous variables in order to have robustness tests automatised and results saved down in prespecified locations. However, if it's not possible I will need to go in the alternative of if structures with code replication.
many
many
Re: Replacement in for loop works on only in first step
thanks (submitted too early)
Who is online
Users browsing this forum: No registered users and 2 guests
