Page 1 of 1

smpl if in loop

Posted: Mon Apr 08, 2019 8:08 am
by Frdmn
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!

Re: smpl if in loop

Posted: Mon Apr 08, 2019 8:23 am
by EViews Gareth
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

Re: smpl if in loop

Posted: Mon Apr 08, 2019 8:35 am
by Frdmn
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?

Re: smpl if in loop

Posted: Mon Apr 08, 2019 8:55 am
by EViews Gareth
What's the build date on your copy of 10? (Help->About EViews)

Re: smpl if in loop

Posted: Mon Apr 08, 2019 9:02 am
by Frdmn
it says Mar 22 2019 build, I'm not administrator*
I installed EViews 11 and your code works on this version.

Re: smpl if in loop

Posted: Mon Apr 08, 2019 9:07 am
by EViews Gareth
When you run the program in 10, make sure the "version 4 compatible mode" is unchecked.

Re: smpl if in loop

Posted: Mon Apr 08, 2019 10:35 am
by Frdmn
Amazing Gareth, you're the man!