smpl if in loop

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

Frdmn
Posts: 13
Joined: Sat Aug 11, 2018 5:44 am

smpl if in loop

Postby Frdmn » Mon Apr 08, 2019 8:08 am

Hello,

I'm trying to create pages based on cross sectional attributes (my cross-sections are countries and I want to create a new page and sample if countries are in a specific region, like Asia of Latin America.

The code is the following:

Code: Select all

%sub_region = @wjoin(@uniquevals(sub_region_code))
for %i {%sub_region}
pageselect Baseline
pagecopy(page={%i},nolinks)
smpl if sub_region_code=%i
next




But Eviews outputs the following error (SUBAFR is my first sub_region, in all caps):

Code: Select all

Error in Sample:  SUBAFR is not defined in "SMPL IF
 SUB_REGION_CODE=SUBAFR".


Is anyone having the same issues? this is EViews 10.

Thanks!

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

Re: smpl if in loop

Postby EViews Gareth » Mon Apr 08, 2019 8:23 am

There's nothing inherently wrong - this seems to work:

Code: Select all

'create a panel with some cross-sections identified by sub_region_code
wfcreate(page=Baseline) a 1990 2000 15
alpha sub_region_code = "sub_" + @str(@crossid)
pagestruct() sub_region_code @date(dateid)

%sub_region = @wjoin(@uniquevals(sub_region_code))
for %i {%sub_region}
   pageselect Baseline
   pagecopy(page={%i},nolinks)
   smpl if sub_region_code=%i
next
Follow us on Twitter @IHSEViews

Frdmn
Posts: 13
Joined: Sat Aug 11, 2018 5:44 am

Re: smpl if in loop

Postby Frdmn » Mon Apr 08, 2019 8:35 am

Thanks for your quick response Gareth, but this doesn't work on my version of EViews,it throws the following error:

Error in Sample: SUB_1 is not defined in "SMPL IF
SUB_REGION_CODE=SUB_1".


Any clue? maybe case sensitivity? Maybe trying EViews 11?

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

Re: smpl if in loop

Postby EViews Gareth » Mon Apr 08, 2019 8:55 am

What's the build date on your copy of 10? (Help->About EViews)
Follow us on Twitter @IHSEViews

Frdmn
Posts: 13
Joined: Sat Aug 11, 2018 5:44 am

Re: smpl if in loop

Postby Frdmn » Mon Apr 08, 2019 9:02 am

it says Mar 22 2019 build, I'm not administrator*
I installed EViews 11 and your code works on this version.

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

Re: smpl if in loop

Postby EViews Gareth » Mon Apr 08, 2019 9:07 am

When you run the program in 10, make sure the "version 4 compatible mode" is unchecked.
Follow us on Twitter @IHSEViews

Frdmn
Posts: 13
Joined: Sat Aug 11, 2018 5:44 am

Re: smpl if in loop

Postby Frdmn » Mon Apr 08, 2019 10:35 am

Amazing Gareth, you're the man!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 4 guests