Working on a program that was originally written in eviews 4, running in eviews 7.
For the following lines of code
%kda = %k + "dpp"
series {%k}dpp = d({%k})
I get the error message:
Can not assign string expression to numeric variable in "SERIES %KDPP = D(AMBER_0)
Where AMBER_0 is the variable name
I am simply trying to calculate the level change for each variable
Thank you.
string expression to numeric variable
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: string expression to numeric variable
That should work:
No error, and series calculates correctly in EV72.
Code: Select all
create u 100
series x=nrnd
%k = "x"
series {%k}dpp = d({%k})
Re: string expression to numeric variable
It seems to work for 1 variable, but I am having trouble getting it to go through a list of variables as in this:
FOR !k = 3 to VarList1.@count
%k = VarList1.@seriesname(!k)
create u 100
series x=nrnd
%k = "x"
series {%k}dpp = d({%k})
When I run it, I get x and xdpp created, but then I get an error message for that says "VarList1 is not defined in "%K = VarList1.@SERIESNAME(4)"."
Thank you.
FOR !k = 3 to VarList1.@count
%k = VarList1.@seriesname(!k)
create u 100
series x=nrnd
%k = "x"
series {%k}dpp = d({%k})
When I run it, I get x and xdpp created, but then I get an error message for that says "VarList1 is not defined in "%K = VarList1.@SERIESNAME(4)"."
Thank you.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: string expression to numeric variable
That's because the "create" command creates a new workfile, and as soon as you're on a new workfile, varlist1 doesn't exist any more.
Re: string expression to numeric variable
ok, when I go to this:
FOR !k = 3 to VarList1.@count
%k = VarList1.@seriesname(!k)
series {%k}dpp = d({%k})
NEXT
I'm back to my error message of "Can not assign string expression to numeric variable in "SERIES {%K}DPP = D(AMBER_0))". Where AMBER_0 is the a variable name in my variable list
FOR !k = 3 to VarList1.@count
%k = VarList1.@seriesname(!k)
series {%k}dpp = d({%k})
NEXT
I'm back to my error message of "Can not assign string expression to numeric variable in "SERIES {%K}DPP = D(AMBER_0))". Where AMBER_0 is the a variable name in my variable list
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: string expression to numeric variable
Code: Select all
create u 100
series x1=nrnd
series x2=nrnd
series x3=nrnd
series x4=nrnd
series amber_0=nrnd
group VarList1 x1 x2 x3 x4 amber_0
FOR !k = 3 to VarList1.@count
%k = VarList1.@seriesname(!k)
series {%k}dpp = d({%k})
NEXT
Re: string expression to numeric variable
Thank you. Sorry, I was missing brackets around a %k in the following code when I defined the variables so they were not numerical values.
FOR !k = 3 to VarList1.@count
%k = VarList1.@seriesname(!k)
GENR {%k}_0 = {%k}
NEXT
One more question, in the code above, when it makes the variable {%k}_0, it only put the value from {%k} into the last observation point.
For example, if %k is on a variable named AMBER, and AMBER has numerical values from 1999:Q1 through 2010:Q4, the above code generated AMBER_0, but only puts a value in the 2010:Q4 cell. The value in the 2010:Q4 cell matches the AMBER 2010:Q4 value, but all other cells from 1999:Q1 to 2010:Q3 have NA in them for AMBER_0, whereas AMBER has numbers.
Any ideas?
FOR !k = 3 to VarList1.@count
%k = VarList1.@seriesname(!k)
GENR {%k}_0 = {%k}
NEXT
One more question, in the code above, when it makes the variable {%k}_0, it only put the value from {%k} into the last observation point.
For example, if %k is on a variable named AMBER, and AMBER has numerical values from 1999:Q1 through 2010:Q4, the above code generated AMBER_0, but only puts a value in the 2010:Q4 cell. The value in the 2010:Q4 cell matches the AMBER 2010:Q4 value, but all other cells from 1999:Q1 to 2010:Q3 have NA in them for AMBER_0, whereas AMBER has numbers.
Any ideas?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: string expression to numeric variable
Code: Select all
create q 1999q1 2010q4
series x1=nrnd
series x2=nrnd
series x3=nrnd
series amber_0=nrnd
group VarList1 x1 x2 x3 amber_0
FOR !k = 3 to VarList1.@count
%k = VarList1.@seriesname(!k)
GENR {%k}_0 = {%k}
NEXT
show amber_0
Who is online
Users browsing this forum: JMviews and 1 guest
