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
If statement within a loop for panel data
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
If statement within a loop for panel data
Last edited by sky22 on Wed Mar 03, 2021 2:09 pm, edited 2 times in total.
-
- Non-normality and collinearity are NOT problems!
- Posts: 3775
- Joined: Wed Sep 17, 2008 2:25 pm
Re: If statement within a loop
Try
Code: Select all
smpl if year = !yr
inf=f{!yr}cpi
smpl @all
Re: If statement within a loop
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?
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?
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: If statement within a loop for panel data
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?
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?
Who is online
Users browsing this forum: No registered users and 39 guests