Page 1 of 1

If statement within a loop for panel data

Posted: Wed Mar 03, 2021 1:47 pm
by sky22
I need advice on a simple program I am trying to run which does not work. I want to include an IF statement within a loop. The data is a panel series in long form, so variable year is a repeated series

SERIES INF
For !YR=1990 to 2017
If year =!yr then
GENR inf=f{!yr}cpi
endif
next

The series inf remains blank. How do i fix this?
thank you

Re: If statement within a loop

Posted: Wed Mar 03, 2021 1:59 pm
by startz
Try

Code: Select all

smpl if year = !yr inf=f{!yr}cpi smpl @all

Re: If statement within a loop

Posted: Wed Mar 03, 2021 2:07 pm
by sky22
Hi
thank you but the smpl function does not work as the data is a panel. so the sample is country and time. I have a separate variable for year and country.
Is there a way around this?

Re: If statement within a loop for panel data

Posted: Fri Mar 05, 2021 2:40 pm
by EViews Matt
Hello,

If you're saying that variable "year" is a series, then the "year = !yr" expression is not meaningful as part of an if statement conditional. Can you describe what you're trying to accomplish with your code?