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

rename dummy and diagonal dummy

Postby clubmed » Wed Mar 29, 2017 7:40 am

Dear All,
I have 192 observations (16 years and 12 month) frequency monthly, the function @expand(@month) and @expand(@year) create directly dummy by monthly or by year. but when i combined month and year show expand(@month * @year) i get 192 dummy. now i have two questions:
1- how can rename the dummy series the identify it corectly ( d_2000_1 dummy for the 1st month of year 2000, d_2000_2 dummy for the 2st month of year 2000...etc).
2- how can i get digonal dummy because the expand(@month * @year) function make iregular dummy.

Thanks in Advance.

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

Re: rename dummy and diagonal dummy

Postby EViews Gareth » Wed Mar 29, 2017 8:21 am

You'll have to make them manually rather than by using @expand. A couple of for loops (one for month, one for year) in a program would do it.
Follow us on Twitter @IHSEViews

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

Re: rename dummy and diagonal dummy

Postby clubmed » Wed Mar 29, 2017 9:08 am

ok, i have no choice i will do it manually. :(

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

Re: rename dummy and diagonal dummy

Postby clubmed » Wed Mar 29, 2017 9:47 am

Manually take long time :roll: , could you guide me for some few lines for the program.

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

Re: rename dummy and diagonal dummy

Postby EViews Gareth » Wed Mar 29, 2017 10:07 am

Code: Select all

for !y=2000 to 2016
   for !m=1 to 12
      series d_{!y}_{!m} = 0         
   next
next

for !y=2000 to 2016
   for !m=1 to 12
      smpl if @year=!y and @month=!m
      series d_{!y}_{!m} = 1
   next
next
Follow us on Twitter @IHSEViews

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

Re: rename dummy and diagonal dummy

Postby clubmed » Wed Mar 29, 2017 12:35 pm

Many thanks Mr Gareth. :)
1/how to put number zero at left of d_{!y}_0{!m} just for the nine series ( jan to oct) for every year (to arrange the series in workfile), if i add number zero in program Its adds the number zero for all series 01, 02,....010, 011, 012.
i need this:
d_2000_01
d_2000_02
........
d_2000_10
d_2000_11
d_2000_12
d_2001_01
.......
2/i have make some mini modification in your program with @otod (to arrange series d_) but i get the value 1 for all series.

Code: Select all

for !i = 1 to @obsrange
   %dt = @otod(!i)
next
  for !y=2000 to 2016
     for !m=1 to 12
      series d_{%dt}= 0         
     next
  next

for !i = 1 to @obsrange
   %dt = @otod(!i)
next
for !y=2000 to 2016
   for !m=1 to 12
      smpl if @year=!y and @month=!m
      series d_{%dt}= 1
   next
next
smpl @all
group dum d*

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

Re: rename dummy and diagonal dummy

Postby clubmed » Wed Mar 29, 2017 4:07 pm

1/ solved.
Last edited by clubmed on Thu Mar 30, 2017 1:21 am, edited 1 time in total.

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

Re: rename dummy and diagonal dummy

Postby clubmed » Thu Mar 30, 2017 12:50 am

2/ (another way with @otod function) with this program i get all dummy variable series in the workfile but not the value 1.

Code: Select all

for !i = 1 to @obsrange
   %dt = @otod(!i)

    for !y=2000 to 2015
           for !m=1 to 12
      series d_{%dt}= 0         
     next
  next
next

for !y=2000 to 2015
   for !m=1 to 12
      smpl if @year=!y and @month=!m
      series d_{%dt}= 1
   next
next
smpl @all
group dum d*

3/ if the frequency will by weekly or daily, there is two problem:
a) here some year contaned 365 or 366 days, and 52 or 53 week.
b) the program bellow (doesn' work corectly) generate 53 dummy series but some year contaned 52 or 53 week, how can generate 52 dummy in year thay contaned 52 week, and generate 53 dummy in year thay contaned 53 week. (bacause that generate 53th series with value zero for the year that contaned 52 week).
have you understand me. :(

Code: Select all

for !y=2000 to 2015
   for !m=1 to 12
for !w=1 to 53
      series d_{!y}_{!m}_{!w} = 0         
   next
next
next

for !y=2000 to 2015
   for !m=1 to 12
for !w=1 to 53
      smpl if @year=!y and @month=!m @datepart(@date, "ww")=!w
      series d_{!y}_{!m}_{!w} = 1
   next
next
next
smpl @all
group dum d*

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

Re: rename dummy and diagonal dummy

Postby clubmed » Thu Mar 30, 2017 11:50 am

I have modified your 1st program for weekly frequency but it doesn't work correctly and it take long time to show result( probably @otod function can solve this problem or by if loop.), could you help me please Mr Gareth. :cry:
Attachments
dum_week.prg
(2.39 KiB) Downloaded 120 times

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

Re: rename dummy and diagonal dummy

Postby EViews Gareth » Thu Mar 30, 2017 12:09 pm

I have no idea what you're trying to do.
Follow us on Twitter @IHSEViews

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

Re: rename dummy and diagonal dummy

Postby clubmed » Thu Mar 30, 2017 1:46 pm

I have 835 observations 16 year frequency weekly, and 3 year with 1094 observations daily frequency, and 2 year inerday 30 min frequency (08:00, 08:30, 09:00).
1/how can create and rename 835 dummy series to identify it corectly d_{year}_{month}_{weekly}, the month and week should be in double number (jan=01 not jan=1) to order it in the workfile.
d_2000_01_03 (not d_2000_1_3)
d_2000_01_10
d_2000_01_17
d_2000_01_24
d_2000_01_31
d_2000_02_07...etc

2/how can create and rename 1094 dummy series to identify it corectly d_{year}_{month}_{daily}. the month and daily should be in double number 01 02 03...etc
d_2000_01_03 (not d_2000_1_3)
d_2000_01_04,...etc

3/how can create and rename 1563 dummy series to identify it corectly d_{year}_{month}_{daily}_{hour}_{min}. the month, hour and min should be in double number,
d_2000_01_03_08_00 (not d_2000_1_3_8_0)
d_2000_01_03_08_30
d_2000_01_03_09_00
d_2000_01_04_08_00
d_2000_01_04_08_30
d_2000_01_04_09_00
d_2000_01_05_08_00...etc

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

Re: rename dummy and diagonal dummy

Postby EViews Gareth » Thu Mar 30, 2017 2:09 pm

clubmed wrote:I have 835 observations 16 year frequency weekly, and 3 year with 1094 observations daily frequency, and 2 year inerday 30 min frequency (08:00, 08:30, 09:00).
1/how can create and rename 835 dummy series to identify it corectly d_{year}_{month}_{weekly}, the month and week should be in double number (jan=01 not jan=1) to order it in the workfile.
d_2000_01_03 (not d_2000_1_3)
d_2000_01_10
d_2000_01_17
d_2000_01_24
d_2000_01_31
d_2000_02_07...etc

How are you defining which month a week is in?
2/how can create and rename 1094 dummy series to identify it corectly d_{year}_{month}_{daily}. the month and daily should be in double number 01 02 03...etc
d_2000_01_03 (not d_2000_1_3)
d_2000_01_04,...etc

Code: Select all

create d7 2000 2016

for !y=2000 to 2016
   %y = @str(!y)
   if !y<10 then
      %y = "0"+%y
   endif
   for !m=1 to 12
      %m = @str(!m)
      if !m<10 then
         %m = "0"+%m
      endif
      for !d=1 to 31
         %d = @str(!d)
         if !d<10 then
            %d = "0"+%d
         endif
         series d_{%y}_{%m}_{%d} = @recode(@year=!y and @month=!m and @day=!d, 1, 0)
         
      next
   next
next



3/how can create and rename 1563 dummy series to identify it corectly d_{year}_{month}_{daily}_{hour}_{min}. the month, hour and min should be in double number,
d_2000_01_03_08_00 (not d_2000_1_3_8_0)
d_2000_01_03_08_30
d_2000_01_03_09_00
d_2000_01_04_08_00
d_2000_01_04_08_30
d_2000_01_04_09_00
d_2000_01_05_08_00...etc

See above.
Follow us on Twitter @IHSEViews

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

Re: rename dummy and diagonal dummy

Postby clubmed » Fri Mar 31, 2017 1:26 am

a) I have two weekly serie: the first series with weekly frequency defining by Monday (03/01/2000 28/12/2015) , and second series weekly frequency defining by Wednesday ( 05/01/2000 25/12/2002).
b) the program work perfectly, but some years have February with 28 days and others with 29 days (in leap years), same with month with 30 days and 31 days, the program create 31 dummy for each month, this will create some series empty and unuseful. (for example: d_2000_02_30, d_2000_02_31 and d_2000_04_31), this is an impact for create and rename series with frequency daily weekly and interday.
c) is there a solution for interday, February with 28 days and others with 29 days (in leap years) and some month with 30 and 31 days.
d_2000_01_03_08_00
d_2000_01_03_08_30
d_2000_01_03_09_00

d_2000_01_04_08_00
d_2000_01_04_08_30
d_2000_01_04_09_00....etc

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

Re: rename dummy and diagonal dummy

Postby clubmed » Fri Mar 31, 2017 10:48 am

have you understand me Mr Gareth.

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

Re: rename dummy and diagonal dummy

Postby EViews Gareth » Fri Mar 31, 2017 11:17 am

a) doesn't answer the question.

b) Probably easiest for you just to handle it manually (delete the ones you don't want). There's a limit to how much free program writing we can do.
Follow us on Twitter @IHSEViews


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 7 guests