Naming Variables in Loop

For questions regarding programming in the EViews programming language.

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

cmgconsulting
Posts: 38
Joined: Mon Nov 17, 2008 8:25 am

Naming Variables in Loop

Postby cmgconsulting » Mon Nov 17, 2008 3:13 pm

How can I name an equation after a value in an alpha variable instead of e1, e2, e3... see program below:

spool myspool
for !i=1 to 134
smpl if @crossid = !i
equation e{!i}
e{!i}.ls ssu c price acv items promoacv promounits @trend(1) @expand(period,@dropfirst) easter
myspool.append e{!i}.stats
next

I would like my regressions to be named after the first value in a variable named "COT" instead of e1, e2, e3...

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

Re: Naming Variables in Loop

Postby EViews Gareth » Mon Nov 17, 2008 4:00 pm

Here you go:

Code: Select all

spool myspool
series obsnum = @obsnum
for !i=1 to 134
smpl if @crossid = !i
%cxname = alpha(@min(obsnum))
%eqname = "e_" + %cxname
equation {%eqname}.ls ssu c price acv items promoacv promounits @trend(1) @expand(period,@dropfirst) easter
myspool.append {%eqname}.stats
next



Where ALPHA is the name of the alpha series.
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 42 guests