How to use IF command

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

truetears
Posts: 14
Joined: Sat Aug 04, 2012 7:57 am

How to use IF command

Postby truetears » Fri Aug 31, 2012 3:30 am

Hi guys, I want to know how I can use the IF command to restrict the data group to only specific values, what I mean is, in the file attached, in the "distance" group, I want to restrict the spreadsheet so that it only shows values for which distance>7403.77, how do I do this?

Thanks :)
Attachments
a2data_id1_2.wf1
(116.01 KiB) Downloaded 318 times

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

Re: How to use IF command

Postby EViews Gareth » Fri Aug 31, 2012 6:31 am

You need to use a sample.

Code: Select all

smpl if x>7

truetears
Posts: 14
Joined: Sat Aug 04, 2012 7:57 am

Re: How to use IF command

Postby truetears » Fri Aug 31, 2012 8:05 am

Sorry I am quite new to Eviews 7, what exactly does that mean? I have clicked on window and enter in "distance > 7403.77" in the IF space, then it comes up with the number of observations which satisfies the IF condition, however I wish to actually restrict the spreadsheet of the group "distance" such that only the observations that are greater than 7403.77 are shown rather than the whole spreadsheet.

Thanks!

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

Re: How to use IF command

Postby EViews Gareth » Fri Aug 31, 2012 8:13 am

That's exactly what you have done.

truetears
Posts: 14
Joined: Sat Aug 04, 2012 7:57 am

Re: How to use IF command

Postby truetears » Fri Aug 31, 2012 8:32 am

That's exactly what you have done.
But when I open up "distance" it still shows me all 1000 observations? I can't see the 221 restricted observations.

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

Re: How to use IF command

Postby EViews Gareth » Fri Aug 31, 2012 8:55 am

Hit the SMPL +/- button.

truetears
Posts: 14
Joined: Sat Aug 04, 2012 7:57 am

Re: How to use IF command

Postby truetears » Fri Aug 31, 2012 9:23 am

Thank you! exactly what I was looking for :)

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

Re: How to use IF command

Postby EViews Gareth » Fri Aug 31, 2012 9:25 am

Note that hitting the SMPL+/- button only changes the view you are currently looking at. The current sample is applied to any statistics you perform, whether or not you have hit that button.

truetears
Posts: 14
Joined: Sat Aug 04, 2012 7:57 am

Re: How to use IF command

Postby truetears » Fri Aug 31, 2012 10:58 am

Ahh I see, thanks for that, just out of curiosity then, how would I be able to use only the restricted sample in regression analysis?

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

Re: How to use IF command

Postby EViews Gareth » Fri Aug 31, 2012 11:14 am

By default it will use the restricted sample - as I said, once you have set the restricted sample it generally gets used for everything you do after that.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests