Page 2 of 2

Re: @recode

Posted: Wed Jun 27, 2018 10:30 pm
by shineK
Hi Matt,

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

Best,

Re: @recode

Posted: Thu Jun 28, 2018 9:03 am
by EViews Matt
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 14413 times

Re: @recode

Posted: Thu Jun 28, 2018 9:46 pm
by shineK
Hi Matt,

OK! I found it!
Thank you :D :D :D

Re: @recode

Posted: Mon Jul 02, 2018 12:40 am
by shineK
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
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

Re: @recode

Posted: Mon Jul 02, 2018 10:11 am
by EViews Matt
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

Re: @recode

Posted: Tue Jul 03, 2018 3:43 am
by shineK
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!!!!!!!!!!!!!!!!!

Re: @recode

Posted: Tue Jul 03, 2018 3:52 am
by shineK
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)

Re: @recode

Posted: Tue Jul 03, 2018 5:34 am
by shineK
Hi Matt,

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