Page 5 of 5

Re: rename dummy and diagonal dummy

Posted: Mon May 01, 2017 11:30 am
by clubmed
It worked now with alpha series, but if the identification a series crossid =(1 1 1 1..., 2 2 2 2..., 3 3 3....) i get error message
" String added to scalar in "%SERIES_NAME = "D_"+CROSSID(1) + "_"+@DATESTR(@DATEVAL(@OTOD((1 - 1) * 3 + 1)), "YYYY_MM_DD_")+ @STR(1, "I03")"."

Re: rename dummy and diagonal dummy

Posted: Mon May 01, 2017 11:49 am
by EViews Matt
I believe @crossid cannot be used in a scalar expression like that, but you could save @crossid to a series and then access an element of that series instead.

Re: rename dummy and diagonal dummy

Posted: Mon May 01, 2017 11:57 am
by clubmed
i have make this series identif=@crossid i get the same error message how can solve this.
%series_name = "d_"+ identif(!i) + "_"+...
*) i have series named crossid in my workfile (1 1 1 1...,2222...)

Re: rename dummy and diagonal dummy

Posted: Mon May 01, 2017 1:05 pm
by EViews Matt
Silly me, I forgot to mention the string conversion. I also thought you meant @crossid, but if you already have a series crossid:

Code: Select all

%series_name = "d_" + @str(crossid(!i)) + "_" + ...

Re: rename dummy and diagonal dummy

Posted: Mon May 01, 2017 2:53 pm
by clubmed
Perfectly all named series works, you are not silly ok!.
could i generate this series dummy, i mean to generate just 4 dummy series ok, but it generate 8 series dummy contained zero value

Code: Select all

wfcreate 30min(Mon-Fri,8:00-9:00) 03/01/2000 06/01/2000 3 !size = 3 ' Every four observations go into one dummy. for !i = 1 to @obsrange !id = @floor((!i - 1) / !size) + 1 %series_name = "d_" + @str(!id, "i03") if not @isobject(%series_name) then series {%series_name} = @floor(@trend / !size) + 1 = !id endif next

Re: rename dummy and diagonal dummy

Posted: Mon May 01, 2017 3:18 pm
by EViews Matt
Sure, since you have three cross sections just change the upper limit of the for loop from @obsrange to @obsrange / 3.

Re: rename dummy and diagonal dummy

Posted: Mon May 01, 2017 3:36 pm
by clubmed
How can referenced your code in my study. Should i write just EViews Matt Developer.
Thank you for your help. Thanks for all your efforts to make this possible. :)
See you soon.

Re: rename dummy and diagonal dummy

Posted: Mon May 01, 2017 3:44 pm
by EViews Matt
I believe you can just refer to the EViews development team.

Re: rename dummy and diagonal dummy

Posted: Mon May 01, 2017 3:50 pm
by clubmed
Nice. 8)

Re: rename dummy and diagonal dummy

Posted: Tue May 02, 2017 9:04 am
by metrix
Hi everybody,
Can i fix this case with another way (without @isna and @nan), i have the same case with my data series.
series tx = @recode(@day<>@day(-1) or @isna(@day(-1)), 1, tx(-1) + 1)
series break=@recode(@during("2000m01 2001m05") or @during("2003m10 2004m12") or @during("2006m01 2007m04") or @during("2008m01 2015m02"), @nan(break(-1), 0) + 1, 0)

Re: rename dummy and diagonal dummy

Posted: Tue May 02, 2017 9:14 am
by EViews Matt
Hello,

Is there some reason you don't want to use @isna or @nan? Those functions let one concisely create the series.

Re: rename dummy and diagonal dummy

Posted: Tue May 02, 2017 9:52 am
by metrix
just to see how can fix the two cases by another ways, to understand the logic without functions.

Re: rename dummy and diagonal dummy

Posted: Tue May 02, 2017 10:18 am
by metrix
could you respond me please. :)

Re: rename dummy and diagonal dummy

Posted: Tue May 02, 2017 12:16 pm
by EViews Matt
I see. Well, the basic logic behind both those series generating expressions is this: given some condition, either make the next value in the series one more than the preceding value, or set it to a specific value. Using the tx series as an example, you could write an equivalent program that explicitly assigns each value:

Code: Select all

series tx tx(1) = 1 for !i = 2 to @obsrange if @datepart(@dateval(@otod(!i)), "dd") <> @datepart(@dateval(@otod(!i - 1)), "dd") then tx(!i) = 1 else tx(!i) = tx(!i - 1) + 1 endif next
The first value in the series is fixed at 1, and for the rest of the observations the code checks for the transition to a new day. When a new day is found, the series' value for that observation is set to 1. Otherwise, the series' value is one more than the preceding value.

The above program isn't very big, but you can generate the same data in fewer lines by taking advantage of other EViews capabilities. Sort of half-way between the above program and the one-line solution would be:

Code: Select all

series tx tx(1) = 1 smpl @first+1 @last tx = @recode(@day <> @day(-1), 1, tx(-1) + 1)
The for loop and everything inside it have been replaced by @recode. However, the logic of tx(-1) + 1 only makes sense from the second observation onwards. tx(-1) is NA for the first observation, thus tx(-1) + 1 will be NA, which isn't what we want. The smpl line is there to make sure that the @recode logic skips the first observation. Since the first observation is skipped, we have to explicitly set it ourselves, which is done before the sample line.

Because the series is defined in terms of its own lag, we had to set the first observation differently than the other observations. A more concise way to do this is to use @isna or @nan to detect that special case directly within the @recode expression.

Code: Select all

series tx = @recode(@day <> @day(-1) or @isna(@day(-1)), 1, tx(-1) + 1)

Re: rename dummy and diagonal dummy

Posted: Tue May 02, 2017 1:41 pm
by metrix
I understand well now, Thanks for your quick response. :)