I need to compare two GDP series, one is 1970-2009 and the other is 1980-2009. So the first has more history. But I only want to compare over 1980-2009. I tried
smpl 1980 2009
and then did
if ser1=ser2 then...
But I got errors due to the NAs in 1970-1979 in the later-starting series.
Q: Is there any way to make the IF condition look at the current sample years only?
TIA,
Dan
IF statement: make it limited to sample?
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: IF statement: make it limited to sample?
Not clear what you're trying to do.
You can never use if to compare two series.
You can never use if to compare two series.
Re: IF statement: make it limited to sample?
Are you sure? I just did a simple test:Not clear what you're trying to do.
You can never use if to compare two series.
Made these series
Year ser1 ser2
2001 1.0 1.0
2002 2.5 2.5
2003 3.0 3.0
2004 4.0 4.0
then ran this program
text res1
if ser1=ser2 then
res1.append "ser1=ser2"
endif
and the text was pasted into the text box.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: IF statement: make it limited to sample?
Edit: I'm losing my mind. This post made no sense.
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: IF statement: make it limited to sample?
In case it's helpful, the manual says
You should take care when using the IF statement with series or matrices to note that the comparison is defined on the entire object and will evaluate to false unless every element of the element-wise comparison is true.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: IF statement: make it limited to sample?
My previous (now edited) post was completely wrong, sorry.
I'm still not sure what you are trying to do though.
You're just trying to test whether two series are identical over a sub-sample?
I'm still not sure what you are trying to do though.
You're just trying to test whether two series are identical over a sub-sample?
Re: IF statement: make it limited to sample?
Yes, exactly. Suppose I haveI'm still not sure what you are trying to do though.
You're just trying to test whether two series are identical over a sub-sample?
Year ser1 ser2
2000 1.0 NA
2001 2.0 2.0
2002 3.0 3.0
2003 4.0 4.0
I did
smpl 2001 2003
but then the statement
if ser1=ser2 then ..
yielded an error because of the NA in 2000. I thought 'smpl 2001 2003' would avoid that.
So basically I'm looking for a way to check equality in 2001-2003. Any ideas would be welcome.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: IF statement: make it limited to sample?
As I said, you shouldn't really use an if statement on a series.
Perhaps the best way to do it would be something like:
i.e. create a dummy variable equal to 1 whenever the two series are equal, and 0 if they're not. Then compare the sum of that dummy variable with the total number of observations in the sample.
Perhaps the best way to do it would be something like:
Code: Select all
series equal = (ser1=ser2)
smpl 2001 2003
if @sum(equal)=@obssmpl then
blah blah blah
endif
Re: IF statement: make it limited to sample?
Thanks, that looks good.
It's possible one of the series might have an NA in the sample period; I'll try to find a function to use on @sum(equal) to check for that.
It's possible one of the series might have an NA in the sample period; I'll try to find a function to use on @sum(equal) to check for that.
Who is online
Users browsing this forum: No registered users and 2 guests
