one step in loop summation not executed

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator

frankhespeler
Posts: 5
Joined: Tue Jun 05, 2018 10:26 am

one step in loop summation not executed

Postby frankhespeler » Thu Jun 07, 2018 7:44 pm

I execute the following command line six times (in a loop).

{%replacename2_2} = {%replacename2_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename2a})=1,0, {%replacename2a})

Summation works only for the first 5 steps, but not the sixth. When I subsequently compute an additional series as

series ztestsumm = {%replacename2_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename2a})=1,0, {%replacename2a})

summation suddenly works. Is there an obvious reason for this behavior?

many thanks

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11730
Joined: Tue Sep 16, 2008 5:38 pm

Re: one step in loop summation not executed

Postby EViews Gareth » Fri Jun 08, 2018 7:01 am

We'd need more context.
Follow us on Twitter @IHSEViews

frankhespeler
Posts: 5
Joined: Tue Jun 05, 2018 10:26 am

Re: one step in loop summation not executed

Postby frankhespeler » Fri Jun 08, 2018 9:56 am

Not sure whether this can help: i included the entire monsterloop, in which the command line is embedded, and highlighted the command line I sent earlier in red. Again in essence: the loop would add six times new information for the replacement series {%replacename2_2}, which is originally declared and set to series containing exclusively zeros, but it does so only five times. Once I construct a new series doing the addition one time more the result is correct => the last step of the loop is not executed!


for %indicator {indicatoracroloop}

sectoracro = @wnotin(@wnotin(sectoracro, %sectoracroaggexc),"SECAGG OFI OFI2 OFINCLB OFINCLN")

%varname1 = "ind_1_" + %indicator + "_*"
%varname2 = "ind_2_" + %indicator + "_*"
%varname4 = "ind_4_" + %indicator + "_*"
%varname5 = "ind_5_" + %indicator + "_*"
%objectlist1 = @wlookup(%varname1)
%objectlist2= @wlookup(%varname2)
%objectlist4= @wlookup(%varname4)
%objectlist5= @wlookup(%varname5)
!objectnum = @wcount(%objectlist1)

for !z = 1 to !objectnum

%replacename1 =@wdelim(@wleft(@wdelim(@word(%objectlist1,!z),"_"," "),6)," ","_")
%replacename1a =@word(%objectlist1,!z)
%replacename2 = @wmid(@wdelim(%replacename1,"_"," "),4)
%replacename2 = "nfp " + %replacename2
%replacename2 = @wdelim(%replacename2 ," ","_") + "*"
!namenum=@wcount(%replacename2)
if !namenum > 1 then
%replacename3 = @wright(@wlookup(%replacename2),1)
else
%replacename3 = @wright(@wlookup(%replacename2),!namenum)
endif
%indfreq = @lower(@wright(@wdelim(%replacename1,"_"," "),1))

for %country {countryacro}

%exclname = @lower(%indicator)+ "_" + @lower(%country) + "_string"

%country1 = "_" + %country + "_"

if @isobject(%exclname)=1 then 'and {%exclname}.@type= "String"

string sectoracroloc = @wnotin(sectoracro,%exclname)

if @instr(%replacename1, %country1) > 0 and @instr(%replacename3, %country1) > 0 then

for %sector {sectoracroloc}

%sector1 = "_" + %sector + "_"

if @instr(%replacename1, %sector1) > 0 and @instr(%replacename3, %sector1) > 0 then 'or @isobject(%replacename3) )= 1

%existtestname = "denominator_" + %country + "_" + %indfreq

if @isobject(%existtestname) = 0 then 'series creation

series denominator_{%country}_{%indfreq} = 0

endif

denominator_{%country}_{%indfreq} = denominator_{%country}_{%indfreq} + @recode(@isna({%replacename3})=1,0, {%replacename3}) ' @recode({%replacename3}<>0, {%replacename3},NA) 'eliminate 0 entries in NFP series

endif

next

endif

delete sectoracroloc

else

if @instr(%replacename1, %country1) > 0 and @instr(%replacename3, %country1) > 0 then

for %sector {sectoracro}

%sector1 = "_" + %sector + "_"

if @instr(%replacename1, %sector1) > 0 and @instr(%replacename3, %sector1) > 0 then 'or @isobject(%replacename3) )= 1

%existtestname = "denominator_" + %country + "_" + %indfreq

if @isobject(%existtestname) = 0 then 'series creation

series denominator_{%country}_{%indfreq} = 0

endif

denominator_{%country}_{%indfreq} = denominator_{%country}_{%indfreq} + @recode(@isna({%replacename3})=1,0, {%replacename3}) ' @recode({%replacename3}<>0, {%replacename3},NA) 'eliminate 0 entries in NFP series

endif

next

endif

endif

next

next

for !z = 1 to !objectnum

%replacename1 =@wdelim(@wleft(@wdelim(@word(%objectlist1,!z),"_"," "),6)," ","_")
%replacename1a =@word(%objectlist1,!z)
%replacename2 = @wmid(@wdelim(%replacename1,"_"," "),4)
%replacename2 = "nfp " + %replacename2
%replacename2 = @wdelim(%replacename2 ," ","_") + "*"
!namenum=@wcount(%replacename2)
if !namenum > 1 then
%replacename3 = @wright(@wlookup(%replacename2),1)
else
%replacename3 = @wright(@wlookup(%replacename2),!namenum)
endif
%replacename2 =@wdelim(@wleft(@wdelim(@word(%objectlist2,!z),"_"," "),6)," ","_")
%replacename2a =@word(%objectlist2,!z)
%replacename4 =@wdelim(@wleft(@wdelim(@word(%objectlist4,!z),"_"," "),6)," ","_")
%replacename4a =@word(%objectlist4,!z)
%replacename5 =@wdelim(@wleft(@wdelim(@word(%objectlist5,!z),"_"," "),6)," ","_")
%replacename5a =@word(%objectlist5,!z)
%indfreq = @lower(@wright(@wdelim(%replacename1,"_"," "),1))

for %country {countryacro}

%exclname = @lower(%indicator) + "_" + @lower(%country) + "_string"

%country1 = "_" + %country + "_"

if @isobject(%exclname)=1 then 'and {%exclname}.@type= "String"

string sectoracroloc = @wnotin(sectoracro, %exclname)

if @instr(%replacename1, %country1) > 0 and @instr(%replacename3, %country1) > 0 then

for %sector {sectoracroloc}

%sector1 = "_" + %sector + "_"

if @instr(%replacename1, %sector1) > 0 and @instr(%replacename3, %sector1) > 0 and @instr(%replacename1a, %country1) > 0 then 'or @isobject(%replacename3) )= 1

%existtestname = @wdelim(@wleft(@wdelim(@replace(%replacename1,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"

if @isobject(%existtestname) = 0 then 'series creation

%replacename1_1 = @wdelim(@wleft(@wdelim(@replace(%replacename1,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename2_1 = @wdelim(@wleft(@wdelim(@replace(%replacename2,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename4_1 = @wdelim(@wleft(@wdelim(@replace(%replacename4,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename5_1 = @wdelim(@wleft(@wdelim(@replace(%replacename5,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
series {%replacename1_1} =0
series {%replacename2_1} =0
series {%replacename4_1} =0
series {%replacename5_1} =0

else

%replacename1_1 = @wdelim(@wleft(@wdelim(@replace(%replacename1,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename2_1 = @wdelim(@wleft(@wdelim(@replace(%replacename2,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename4_1 = @wdelim(@wleft(@wdelim(@replace(%replacename4,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename5_1 = @wdelim(@wleft(@wdelim(@replace(%replacename5,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"

endif

series weight_{%indicator}_{%sector}_{%country}_{%indfreq} ={%replacename3}/@recode(denominator_{%country}_{%indfreq}<>0, denominator_{%country}_{%indfreq},NA)
{%replacename1_1} = {%replacename1_1} + @recode(@isna(weight_{%indicator}_{%sector}_{%country}_{%indfreq})=1,0,weight_{%indicator}_{%sector}_{%country}_{%indfreq}) * @recode(@isna( {%replacename1a})=1,0, {%replacename1a})
{%replacename2_1} = {%replacename2_1} + @recode(@isna(weight_{%indicator}_{%sector}_{%country}_{%indfreq})=1,0,weight_{%indicator}_{%sector}_{%country}_{%indfreq})* @recode(@isna( {%replacename2a})=1,0, {%replacename2a})
{%replacename4_1} = {%replacename4_1} + @recode(@isna(weight_{%indicator}_{%sector}_{%country}_{%indfreq})=1,0,weight_{%indicator}_{%sector}_{%country}_{%indfreq})* @recode(@isna( {%replacename4a})=1,0, {%replacename4a})
{%replacename5_1} = {%replacename5_1} + @recode(@isna(weight_{%indicator}_{%sector}_{%country}_{%indfreq})=1,0,weight_{%indicator}_{%sector}_{%country}_{%indfreq})* @recode(@isna( {%replacename5a})=1,0, {%replacename5a})

endif

next

endif

delete sectoracroloc

else

if @instr(%replacename1, %country1) > 0 and @instr(%replacename3, %country1) > 0 then

for %sector {sectoracro}

%sector1 = "_" + %sector + "_"

if @instr(%replacename1, %sector1) > 0 and @instr(%replacename3, %sector1) > 0 and @instr(%replacename1a, %country1) > 0 then 'or @isobject(%replacename3) )= 1

%existtestname = @wdelim(@wleft(@wdelim(@replace(%replacename1,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"

if @isobject(%existtestname) = 0 then 'series creation

%replacename1_1 = @wdelim(@wleft(@wdelim(@replace(%replacename1,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename2_1 = @wdelim(@wleft(@wdelim(@replace(%replacename2,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename4_1 = @wdelim(@wleft(@wdelim(@replace(%replacename4,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename5_1 = @wdelim(@wleft(@wdelim(@replace(%replacename5,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
series {%replacename1_1} = 0
series {%replacename2_1} = 0
series {%replacename4_1} = 0
series {%replacename5_1} = 0

else

%replacename1_1 = @wdelim(@wleft(@wdelim(@replace(%replacename1,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename2_1 = @wdelim(@wleft(@wdelim(@replace(%replacename2,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename4_1 = @wdelim(@wleft(@wdelim(@replace(%replacename4,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename5_1 = @wdelim(@wleft(@wdelim(@replace(%replacename5,%sector1,"_secagg_",1),"_"," "),6)," ","_") + "_calc"

endif

series weight_{%indicator}_{%sector}_{%country}_{%indfreq} ={%replacename3}/@recode(denominator_{%country}_{%indfreq}<>0, denominator_{%country}_{%indfreq},NA)
{%replacename1_1} = {%replacename1_1} + @recode(@isna(weight_{%indicator}_{%sector}_{%country}_{%indfreq})=1,0,weight_{%indicator}_{%sector}_{%country}_{%indfreq}) * @recode(@isna( {%replacename1a})=1,0, {%replacename1a})
{%replacename2_1} = {%replacename2_1} + @recode(@isna(weight_{%indicator}_{%sector}_{%country}_{%indfreq})=1,0,weight_{%indicator}_{%sector}_{%country}_{%indfreq})* @recode(@isna( {%replacename2a})=1,0, {%replacename2a})
{%replacename4_1} = {%replacename4_1} + @recode(@isna(weight_{%indicator}_{%sector}_{%country}_{%indfreq})=1,0,weight_{%indicator}_{%sector}_{%country}_{%indfreq}) * @recode(@isna( {%replacename4a})=1,0, {%replacename4a})
{%replacename5_1} = {%replacename5_1} + @recode(@isna(weight_{%indicator}_{%sector}_{%country}_{%indfreq})=1,0,weight_{%indicator}_{%sector}_{%country}_{%indfreq}) * @recode(@isna( {%replacename5a})=1,0, {%replacename5a})

endif

next

endif

endif

next

next

delete denominator*
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' aggregation across countries

sectoracro = @wunion(sectoracro,"SECAGG OFI OFI2 OFINCLB OFINCLN")
countryacro = @wnotin(countryacro,"GL countryagg")
%varname1 = "ind_1_" + %indicator + "_*"
%varname2 = "ind_2_" + %indicator + "_*"
%varname4 = "ind_4_" + %indicator + "_*"
%varname5 = "ind_5_" + %indicator + "_*"
%objectlist1 = @wlookup(%varname1)
%objectlist2= @wlookup(%varname2)
%objectlist4= @wlookup(%varname4)
%objectlist5= @wlookup(%varname5)
!objectnum = @wcount(%objectlist1)

if %indicator = "LEV2" then
string zzztest = @wlookup("ind_2_lev2_*")
endif

for !z = 1 to !objectnum

%replacename1 =@wdelim(@wleft(@wdelim(@word(%objectlist1,!z),"_"," "),6)," ","_")
%replacename1a =@word(%objectlist1,!z)
%replacename2 =@wdelim(@wleft(@wdelim(@word(%objectlist2,!z),"_"," "),6)," ","_")
%replacename2a =@word(%objectlist2,!z)
%replacename4 =@wdelim(@wleft(@wdelim(@word(%objectlist4,!z),"_"," "),6)," ","_")
%replacename4a =@word(%objectlist4,!z)
%replacename5 =@wdelim(@wleft(@wdelim(@word(%objectlist5,!z),"_"," "),6)," ","_")
%replacename5a =@word(%objectlist5,!z)


for %sector {sectoracro}

%sector1 = "_" + %sector + "_"

if @instr(%replacename1, %sector1) > 0 then

for %country {countryacro}

%country1 = "_" + %country + "_"

if @instr(%replacename1, %country1) > 0 then

%existtestname = "denominatorcorr_" + %sector

if @isobject(%existtestname) = 0 then 'series creation

series denominatorcorr_{%sector} = 0

endif

%namecheckEU = @replace(%replacename1,@upper(%country1),"_EU_",1) + "*" '@wleft(@wdelim(@replace(%replacename1,%country2,"_EU",1),"_"," "),3) + "*"
%namecheckEA = @replace(%replacename1,@upper(%country1),"_EA_",1) + "*" '@wleft(@wdelim(@replace(%replacename1,%country2,"_EA",1),"_"," "),3) + "*"
%namecheckNA = @replace(%replacename1,@upper(%country1),"_NA_",1) + "*" '@wleft(@wdelim(@replace(%replacename1,%country2,"_NA",1),"_"," "),3) + "*"
%namecheckEU = @wkeep(%objectlist1,@upper(%namecheckEU))
%namecheckEA = @wkeep(%objectlist1,@upper(%namecheckEA))
%namecheckNA = @wkeep(%objectlist1,@upper(%namecheckNA))

if @wcount(%namecheckNA)=0 then

if @wcount(%namecheckEU)=0 then

if @wcount(%namecheckEA)=0 then

%regionreplace = "nat"
!prestest = @wfindnc("EU EA NA",%country) ' to be updated if country coverage changes

if !prestest = 0 then
denominatorcorr_{%sector} = denominatorcorr_{%sector} + @recode(@isna( gdpdata\weights_{%regionreplace}_{%country})=1,0, gdpdata\weights_{%regionreplace}_{%country}) 'series value update
else
endif

else

%regionreplace = "EA"
!prestest = @wfindnc("AT BE DE EU FI FR IE IT LUX NL NA",%country) ' to be updated if country coverage changes

if !prestest = 0 then
denominatorcorr_{%sector} = denominatorcorr_{%sector} + @recode(@isna( gdpdata\weights_{%regionreplace}_{%country})=1,0, gdpdata\weights_{%regionreplace}_{%country}) 'series value update
else
endif

endif

else

if @wcount(%namecheckEA)=0 then

%regionreplace = "EU"
!prestest = @wfindnc("AT BE DE EA FI FR IE IT LUX NL UK PL NA",%country) ' to be updated if country coverage changes

if !prestest = 0 then
denominatorcorr_{%sector} = denominatorcorr_{%sector} +@recode(@isna( gdpdata\weights_{%regionreplace}_{%country})=1,0, gdpdata\weights_{%regionreplace}_{%country}) 'series value update
else
endif

else

%regionreplace = "EUEA"
!prestest = @wfindnc("AT BE DE FI FR IE IT LUX NL UK PL NA",%country) ' to be updated if country coverage changes

if !prestest = 0 then
denominatorcorr_{%sector} = denominatorcorr_{%sector} +@recode(@isna( gdpdata\weights_{%regionreplace}_{%country})=1,0, gdpdata\weights_{%regionreplace}_{%country}) 'series value update
else
endif

if %comparetemp = "IND_2_LEV2_SECAGG" then

series ztestdenom = denominatorcorr_{%sector}

endif

endif

endif

else

if @wcount(%namecheckEU) =0 then

if %namecheckEA =0 then

%regionreplace = "NA"

!prestest = @wfindnc("US CA EU EA",%country) ' to be updated if country coverage changes

if !prestest = 0 then
denominatorcorr_{%sector} = denominatorcorr_{%sector} +@recode(@isna( gdpdata\weights_{%regionreplace}_{%country})=1,0, gdpdata\weights_{%regionreplace}_{%country}) 'series value update
else
endif

else

%regionreplace = "EANA"

!prestest = @wfindnc("US CA AT BE DE EU FI FR IE IT LUX NL",%country) ' to be updated if country coverage changes

if !prestest = 0 then
denominatorcorr_{%sector} = denominatorcorr_{%sector} + @recode(@isna( gdpdata\weights_{%regionreplace}_{%country})=1,0, gdpdata\weights_{%regionreplace}_{%country}) 'series value update
else
endif

endif

else

if @wcount(%namecheckEA) =0 then

%regionreplace = "EUNA"

!prestest = @wfindnc("US CA AT BE DE FI FR IE IT LUX NL UK PL EA",%country) ' to be updated if country coverage changes

if !prestest = 0 then
denominatorcorr_{%sector} = denominatorcorr_{%sector} + @recode(@isna( gdpdata\weights_{%regionreplace}_{%country})=1,0, gdpdata\weights_{%regionreplace}_{%country}) 'series value update
else
endif

else

%regionreplace = "EUEANA"

!prestest = @wfindnc("US CA AT BE DE FI FR IE IT LUX NL UK PL",%country) ' to be updated if country coverage changes

if !prestest = 0 then
denominatorcorr_{%sector} = denominatorcorr_{%sector} + @recode(@isna( gdpdata\weights_{%regionreplace}_{%country})=1,0, gdpdata\weights_{%regionreplace}_{%country}) 'series value update
else
endif

endif

endif

endif

endif

next

endif

next

for %sector {sectoracro}

%sector1 = "_" + %sector + "_"

if @instr(%replacename1, %sector1) > 0 then

for %country {countryacro}

%country1 = "_" + %country + "_"

if @instr(%replacename1, %country1) > 0 then

%existtestname = @wdelim(@wleft(@wdelim(@replace(%replacename1,%country1,"_countryagg_",1),"_"," "),6)," ","_") + "_calc"

if @isobject(%existtestname) = 0 then 'series creation

%replacename1_2 = @wdelim(@wleft(@wdelim(@replace(%replacename1,%country1,"_countryagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename2_2 = @wdelim(@wleft(@wdelim(@replace(%replacename2,%country1,"_countryagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename4_2 = @wdelim(@wleft(@wdelim(@replace(%replacename4,%country1,"_countryagg_",1),"_"," "),6)," ","_") + "_calc"
%replacename5_2 = @wdelim(@wleft(@wdelim(@replace(%replacename5,%country1,"_countryagg_",1),"_"," "),6)," ","_") + "_calc"
series {%replacename1_2} =0
series {%replacename2_2} =0
series {%replacename4_2} =0
series {%replacename5_2} =0


endif

%namecheckEU = @replace(%replacename1,@upper(%country1),"_EU_",1) + "*" '@wleft(@wdelim(@replace(%replacename1,%country2,"_EU",1),"_"," "),3) + "*"
%namecheckEA = @replace(%replacename1,@upper(%country1),"_EA_",1) + "*" '@wleft(@wdelim(@replace(%replacename1,%country2,"_EA",1),"_"," "),3) + "*"
%namecheckNA = @replace(%replacename1,@upper(%country1),"_NA_",1) + "*" '@wleft(@wdelim(@replace(%replacename1,%country2,"_NA",1),"_"," "),3) + "*"
%namecheckEU = @wkeep(%objectlist1,@upper(%namecheckEU))
%namecheckEA = @wkeep(%objectlist1,@upper(%namecheckEA))
%namecheckNA = @wkeep(%objectlist1,@upper(%namecheckNA))


%comparetemp= @upper(@wdelim(@wleft(@wdelim(%replacename2,"_"," "),5)," ","_"))
if %comparetemp = "IND_2_LEV2_SECAGG_US" then
string zstring = %namecheckEU
string zstring1 = %namecheckEA
string zstring2 = %namecheckNA
endif

if @wcount(%namecheckNA) =0 then

if @wcount(%namecheckEU) =0 then

if @wcount(%namecheckEA) =0 then

%regionreplace = "nat"
!prestest = @wfindnc("EU EA NA",%country) ' to be updated if country coverage changes

if !prestest = 0 then
series weight_{%indicator}_{%country}_{%sector} =gdpdata\weights_{%regionreplace}_{%country}/@recode(denominatorcorr_{%sector}<>0, denominatorcorr_{%sector},NA)
{%replacename1_2} = {%replacename1_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename1a})=1,0, {%replacename1a}) 'series value update
{%replacename2_2} = {%replacename2_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename2a})=1,0, {%replacename2a})
{%replacename4_2} = {%replacename4_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename4a})=1,0, {%replacename4a})
{%replacename5_2} = {%replacename5_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename5a})=1,0, {%replacename5a})

else
endif

else

%regionreplace = "EA"
!prestest = @wfindnc("AT BE DE EU FI FR IE IT LU NL NA",%country) ' to be updated if country coverage changes

if !prestest = 0 then
series weight_{%indicator}_{%country}_{%sector} =gdpdata\weights_{%regionreplace}_{%country}/@recode(denominatorcorr_{%sector}<>0, denominatorcorr_{%sector},NA)
{%replacename1_2} = {%replacename1_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename1a})=1,0, {%replacename1a}) 'series value update
{%replacename2_2} = {%replacename2_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename2a})=1,0, {%replacename2a})
{%replacename4_2} = {%replacename4_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode (@isna({%replacename4a})=1,0, {%replacename4a})
{%replacename5_2} = {%replacename5_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename5a})=1,0, {%replacename5a})

else
endif

endif

else

if @wcount(%namecheckEA) =0 then

%regionreplace = "EU"
!prestest = @wfindnc("AT BE DE EA FI FR IE IT LU NL UK PL NA",%country) ' to be updated if country coverage changes

if !prestest = 0 then
series weight_{%indicator}_{%country}_{%sector} = gdpdata\weights_{%regionreplace}_{%country}/@recode(denominatorcorr_{%sector}<>0, denominatorcorr_{%sector},NA)
{%replacename1_2} = {%replacename1_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename1a})=1,0, {%replacename1a}) 'series value update
{%replacename2_2} = {%replacename2_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename2a})=1,0, {%replacename2a})
{%replacename4_2} = {%replacename4_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename4a})=1,0, {%replacename4a})
{%replacename5_2} = {%replacename5_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename5a})=1,0, {%replacename5a})

else
endif

else

%regionreplace = "EUEA"
!prestest = @wfindnc("AT BE DE FI FR IE IT LUX NL UK PL NA",%country) ' to be updated if country coverage changes

if !prestest = 0 then
series weight_{%indicator}_{%country}_{%sector} = gdpdata\weights_{%regionreplace}_{%country}/@recode(denominatorcorr_{%sector}<>0, denominatorcorr_{%sector},NA)
series {%replacename1_2} = {%replacename1_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename1a})=1,0, {%replacename1a}) 'series value update
series {%replacename2_2} = {%replacename2_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename2a})=1,0, {%replacename2a})
series {%replacename4_2} = {%replacename4_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename4a})=1,0, {%replacename4a})
series {%replacename5_2} = {%replacename5_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename5a})=1,0, {%replacename5a})

' if %comparetemp = "IND_2_LEV2_SECAGG_US" then
' zscalar = zscalar +1
' {%replacename2_2} = {%replacename2_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename2a})=1,0, {%replacename2a})
' series ztestsumm = {%replacename2_2} '+ @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename2a})=1,0, {%replacename2a})
' scalar zscalar2 = !prestest
' string ztestword = %country
' endif

else
endif




endif

endif

else

if @wcount(%namecheckEU) =0 then

if @wcount(%namecheckEA) =0 then

%regionreplace = "NA"
!prestest = @wfindnc("US CA EU EA",%country) ' to be updated if country coverage changes

if !prestest = 0 then
series weight_{%indicator}_{%country}_{%sector} = gdpdata\weights_{%regionreplace}_{%country}/@recode(denominatorcorr_{%sector}<>0, denominatorcorr_{%sector},NA)
{%replacename1_2} = {%replacename1_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename1a})=1,0, {%replacename1a}) 'series value update
{%replacename2_2} = {%replacename2_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename2a})=1,0, {%replacename2a})
{%replacename4_2} = {%replacename4_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename4a})=1,0, {%replacename4a})
{%replacename5_2} = {%replacename5_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename5a})=1,0, {%replacename5a})

else
endif

else

%regionreplace = "EANA"
!prestest = @wfindnc("US CA AT BE DE EU FI FR IE IT LUX NL",%country) ' to be updated if country coverage changes

if !prestest = 0 then
series weight_{%indicator}_{%country}_{%sector} = gdpdata\weights_{%regionreplace}_{%country}/@recode(denominatorcorr_{%sector}<>0, denominatorcorr_{%sector},NA)
{%replacename1_2} = {%replacename1_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename1a})=1,0, {%replacename1a}) 'series value update
{%replacename2_2} = {%replacename2_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename2a})=1,0, {%replacename2a})
{%replacename4_2} = {%replacename4_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename4a})=1,0, {%replacename4a})
{%replacename5_2} = {%replacename5_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename5a})=1,0, {%replacename5a})
else
endif

endif

else

if @wcount(%namecheckEA) =0 then

%regionreplace = "EUNA"
!prestest = @wfindnc("US CA AT BE DE FI FR IE IT LUX NL UK PL EA",%country) ' to be updated if country coverage changes

if !prestest = 0 then
series weight_{%indicator}_{%country}_{%sector} = gdpdata\weights_{%regionreplace}_{%country}/@recode(denominatorcorr_{%sector}<>0, denominatorcorr_{%sector},NA)
{%replacename1_2} = {%replacename1_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename1a})=1,0, {%replacename1a}) 'series value update
{%replacename2_2} = {%replacename2_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename2a})=1,0, {%replacename2a})
{%replacename4_2} = {%replacename4_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename4a})=1,0, {%replacename4a})
{%replacename5_2} = {%replacename5_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename5a})=1,0, {%replacename5a})

else
endif

else

%regionreplace = "EUEANA"
!prestest = @wfindnc("US CA AT BE DE FI FR IE IT LUX NL UK PL",%country) ' to be updated if country coverage changes

if !prestest = 0 then
series weight_{%indicator}_{%country}_{%sector} = gdpdata\weights_{%regionreplace}_{%country}/@recode(denominatorcorr_{%sector}<>0, denominatorcorr_{%sector},NA)
{%replacename1_2} = {%replacename1_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename1a})=1,0, {%replacename1a}) 'series value update
{%replacename2_2} = {%replacename2_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename2a})=1,0, {%replacename2a})
{%replacename4_2} = {%replacename4_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename4a})=1,0, {%replacename4a})
{%replacename5_2} = {%replacename5_2} + @recode(@isna(weight_{%indicator}_{%country}_{%sector})=1,0,weight_{%indicator}_{%country}_{%sector}) * @recode(@isna({%replacename5a})=1,0, {%replacename5a})

else
endif

endif

endif

endif

endif

next

endif

next

next

delete denominator_corr*

countryacro = @wunion(countryacro, "GL COUNTRYAGG")

next

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11730
Joined: Tue Sep 16, 2008 5:38 pm

Re: one step in loop summation not executed

Postby EViews Gareth » Fri Jun 08, 2018 10:04 am

Yeah, that's a bit much to debug by site. You're going to have to debug manually.

I cases like this I like to create a table object outside of the loop, then record all the variables inside the loop so that I can see what is going on.

Something like:

Code: Select all

table temp
temp(1,1) = "!a"
temp(1,2) = "%j"
temp(1,3) = "!i"
!r=2

for %j {%mylist}
  for !i= 1 to 10
  'stuff here involving %j, !i and another variable !a
  temp(!r,1) = !a
  temp(!r,2) = %j
  temp(!r,3) = !i
  !r=!r+1
 next
 
Follow us on Twitter @IHSEViews

frankhespeler
Posts: 5
Joined: Tue Jun 05, 2018 10:26 am

Re: one step in loop summation not executed

Postby frankhespeler » Fri Jun 08, 2018 3:13 pm

Debugging gives me the strange results that I have after the sixth adding operation a nonzero value in the series %replacename2_2 when reporting it to a table, but a zero value in the graph of the actual series. i guess the variable does not date up the latest loop step? What can i do?


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests