Subtraction of panel data with loop
Posted: Tue Dec 17, 2019 7:50 am
Hi,
I have a data panel dim (4,3).
This is the code I use to subtract obsid=2- obsid=3 in crossid=4 for January:
smpl @all if @crossid=4 and @obsid=2
series result=@maxsby(JAN,@crossid=4, @obsid=2) - @maxsby(JAN,@crossid=4,"if @crossid=4 and @obsid=3")
I would like to perform the same subtraction for all @crossid with a loop.
This is the code I am working on:
for !i=1 to 4 'loop over the cross-sections
smpl @all if @crossid=!i and @obsid=2
series loop=@maxsby(JAN,!i, @obsid=2) - @maxsby(JAN,!i, "if @crossid=!i and @obsid=3") 'jan stands for january
next
It returns me the following error:
Error in Sample: !I is not defined in "SERIES
LOOP=@MAXSBY(JAN,1, @OBSID=2) - @MAXSBY(JAN,1, "IF
@CROSSID=!I AND @OBSID=3")".
How should I change the code that it would work properly?
I use EViews version 9.5.
Thank you!
I have a data panel dim (4,3).
This is the code I use to subtract obsid=2- obsid=3 in crossid=4 for January:
smpl @all if @crossid=4 and @obsid=2
series result=@maxsby(JAN,@crossid=4, @obsid=2) - @maxsby(JAN,@crossid=4,"if @crossid=4 and @obsid=3")
I would like to perform the same subtraction for all @crossid with a loop.
This is the code I am working on:
for !i=1 to 4 'loop over the cross-sections
smpl @all if @crossid=!i and @obsid=2
series loop=@maxsby(JAN,!i, @obsid=2) - @maxsby(JAN,!i, "if @crossid=!i and @obsid=3") 'jan stands for january
next
It returns me the following error:
Error in Sample: !I is not defined in "SERIES
LOOP=@MAXSBY(JAN,1, @OBSID=2) - @MAXSBY(JAN,1, "IF
@CROSSID=!I AND @OBSID=3")".
How should I change the code that it would work properly?
I use EViews version 9.5.
Thank you!