@recode

For questions regarding programming in the EViews programming language.

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

shineK
Posts: 24
Joined: Sat Jun 09, 2018 12:23 am
Location: New Taipei City,Taiwan
Contact:

Re: @recode

Postby shineK » Wed Jun 27, 2018 10:30 pm

Hi Matt,

Thanks a lot!!!
By the way, i can't find the place to post my own question, could you show me?

Best,
Best,
SK :D

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

Re: @recode

Postby EViews Matt » Thu Jun 28, 2018 9:03 am

When you're on the topic list page for a board, just press the "New Topic" button. This button is located near both the top (shown below) and bottom of the page.

post.png
post.png (39.5 KiB) Viewed 8319 times

shineK
Posts: 24
Joined: Sat Jun 09, 2018 12:23 am
Location: New Taipei City,Taiwan
Contact:

Re: @recode

Postby shineK » Thu Jun 28, 2018 9:46 pm

Hi Matt,

OK! I found it!
Thank you :D :D :D
Best,
SK :D

shineK
Posts: 24
Joined: Sat Jun 09, 2018 12:23 am
Location: New Taipei City,Taiwan
Contact:

Re: @recode

Postby shineK » Mon Jul 02, 2018 12:40 am

Hi Matt,

I have another problem for merging data, it's a little bit like the question i asked before, and below is the suggestion that you gave me.
but now, I have 2 requirements, i need to comparison the 'ds_s_f' and 'syear'
for example,
if ds_s_f=357299, syear=2005 exist in file AG, then AG_s= the value in file AG

here is the code that i tried to run, but i do not know how to get the specific cell(e.g. 357299,2005)in AG

Code: Select all

group o ser*
stomna(o, om)
rowvector ds = @rowextract(om)
scalar nfirm = @columns(om)
vector dsv = @transpose(ds)

scalar nS = @rows(ds_s_f)
'scalar nC = @rows(ds_c_f)

series AG_s
for !i = 1 to nS
   for !j = 1 to nfirm
      if ds_s_f(!i) = dsv(!j) then
      !y =syear(!i)-1969
      AG_s(!i) = om(!j,!y)
      endif
   next
next
      


EViews Matt wrote:Ah, you want to test if each value in scomp_cusp_al matches ANY value in cusip_alpha, and copy the corresponding type value. @recode is not the way to do this. Basically, you need to manually go through every observation in scomp_cusp_al and search for a matching observation in cusip_alpha.

Code: Select all

series DS_s
for !i = 1 to @obsrange
   if scomp_cusp_al(!i) <> "" then
      for !j = 1 to cusip_alpha.@last
         if scomp_cusp_al(!i) = cusip_alpha(!j) then
            DS_s(!i) = type(!j)
            !j = @obsrange
         endif
      next
   endif
next
Attachments
00.JPG
00.JPG (396.47 KiB) Viewed 8301 times
CUSIP_FF_run.csv
(56.26 KiB) Downloaded 753 times
AG.CSV
(107.55 KiB) Downloaded 765 times
Best,
SK :D

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

Re: @recode

Postby EViews Matt » Mon Jul 02, 2018 10:11 am

I believe part of the issue is that you're attempting to access objects in two different workfiles. It'll be easier to write your program if all the data is in single workfile. My advise would be to copy the AG workfile page to the CUSIP_FF_run workfile (as a new page, and renaming it to AG). You can then do the following at the beginning of your program,

Code: Select all

' Switch to the AG page
pageselect ag
' Build your group and matrix for the AG data
group o ser*
stomna(o, om)
' Switch back to the CUSIP_FF_run page
pageselect cusip_ff_run
' Move the om matrix from the AG page to the CUSIP_FF_run page.
copy ag\om om
delete ag\om

shineK
Posts: 24
Joined: Sat Jun 09, 2018 12:23 am
Location: New Taipei City,Taiwan
Contact:

Re: @recode

Postby shineK » Tue Jul 03, 2018 3:43 am

Hi Matt,

Actually, I only have a cusip_FF_run workfile, and import the AG in the same workfile(please check the attachment)
Where i stuck is that i try to find whether the ds_s_f is in the group om R1, if exist, and find the date(correspond 'syear'), then got the value or NA(as following picture)
But there may have something wrong in my loop, there always show errors(i don't know why '!y' showed that value, '!y' should be the order from header to bottom, e.g. 2005-1969 = 36, pick the no.36 value of the column)...please help to find where i need to modified, or there maybe have another much easier and faster way to solve the problem. :?: :?: :?: Thanks a lot!!!!!!!!!!!!!!!!!
Attachments
11.JPG
error
11.JPG (199.63 KiB) Viewed 8280 times
cusip_ff_run.wf1
(13.44 MiB) Downloaded 277 times
00.JPG
example
00.JPG (372.74 KiB) Viewed 8280 times
Last edited by shineK on Tue Jul 03, 2018 4:09 am, edited 1 time in total.
Best,
SK :D

shineK
Posts: 24
Joined: Sat Jun 09, 2018 12:23 am
Location: New Taipei City,Taiwan
Contact:

Re: @recode

Postby shineK » Tue Jul 03, 2018 3:52 am

By the way,

i need to calculate the yearly return by monthly return, and the period defined as July,t-1 to Jun t, how do i get this kind of period to calculate the annual return???
And, there r another two kinds of control variable(the concept similar as previous), the definition as below
1. buy-and-hold return over Jan(t) to June(t) where t is the portfolio formation year t >> BHRET6_it=[(1+r)_(i,1))*…*(1+r_(i,6) )]-1
2. the 36 months buy-and-hole return over July(t-3) to June(t)
(this two are my major issue, if go through, after may much easier, really need your help, and really really thank you for helping me)
Attachments
RETM_F.xlsx
(1001.01 KiB) Downloaded 751 times
Last edited by shineK on Tue Jul 03, 2018 5:41 am, edited 1 time in total.
Best,
SK :D

shineK
Posts: 24
Joined: Sat Jun 09, 2018 12:23 am
Location: New Taipei City,Taiwan
Contact:

Re: @recode

Postby shineK » Tue Jul 03, 2018 5:34 am

Hi Matt,

I had already solved the first problem, thanks!!! :D
Best,
SK :D


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 10 guests