rename dummy and diagonal dummy

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

clubmed
Posts: 81
Joined: Sun Nov 30, 2014 3:03 am

Re: rename dummy and diagonal dummy

Postby clubmed » Mon May 01, 2017 11:30 am

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")"."

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: rename dummy and diagonal dummy

Postby EViews Matt » Mon May 01, 2017 11:49 am

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.

clubmed
Posts: 81
Joined: Sun Nov 30, 2014 3:03 am

Re: rename dummy and diagonal dummy

Postby clubmed » Mon May 01, 2017 11:57 am

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...)

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: rename dummy and diagonal dummy

Postby EViews Matt » Mon May 01, 2017 1:05 pm

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)) + "_" + ...

clubmed
Posts: 81
Joined: Sun Nov 30, 2014 3:03 am

Re: rename dummy and diagonal dummy

Postby clubmed » Mon May 01, 2017 2:53 pm

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
Attachments
interday_spanning.png
interday_spanning.png (26.88 KiB) Viewed 9673 times

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: rename dummy and diagonal dummy

Postby EViews Matt » Mon May 01, 2017 3:18 pm

Sure, since you have three cross sections just change the upper limit of the for loop from @obsrange to @obsrange / 3.

clubmed
Posts: 81
Joined: Sun Nov 30, 2014 3:03 am

Re: rename dummy and diagonal dummy

Postby clubmed » Mon May 01, 2017 3:36 pm

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.

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: rename dummy and diagonal dummy

Postby EViews Matt » Mon May 01, 2017 3:44 pm

I believe you can just refer to the EViews development team.

clubmed
Posts: 81
Joined: Sun Nov 30, 2014 3:03 am

Re: rename dummy and diagonal dummy

Postby clubmed » Mon May 01, 2017 3:50 pm

Nice. 8)

metrix
Posts: 57
Joined: Sun Dec 08, 2013 9:15 am

Re: rename dummy and diagonal dummy

Postby metrix » Tue May 02, 2017 9:04 am

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)

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: rename dummy and diagonal dummy

Postby EViews Matt » Tue May 02, 2017 9:14 am

Hello,

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

metrix
Posts: 57
Joined: Sun Dec 08, 2013 9:15 am

Re: rename dummy and diagonal dummy

Postby metrix » Tue May 02, 2017 9:52 am

just to see how can fix the two cases by another ways, to understand the logic without functions.

metrix
Posts: 57
Joined: Sun Dec 08, 2013 9:15 am

Re: rename dummy and diagonal dummy

Postby metrix » Tue May 02, 2017 10:18 am

could you respond me please. :)

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: rename dummy and diagonal dummy

Postby EViews Matt » Tue May 02, 2017 12:16 pm

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)

metrix
Posts: 57
Joined: Sun Dec 08, 2013 9:15 am

Re: rename dummy and diagonal dummy

Postby metrix » Tue May 02, 2017 1:41 pm

I understand well now, Thanks for your quick response. :)


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 23 guests