Hi ChrisNZ I sincerely apologies for the late update. I had few issues yesterday and was off hence me not updating you with reference to the codes you sent. Thanks very much for the understanding and really appreciate the great efforts. Please just as you opinionated earlier on, we are getting there. I have run the code and it worked perfectly on the sample above and is very fast of which i tried to follow the codes so i can modify the variables to enable me apply the codes to the bigger data i have but didnt work. Please as i could only indicate the nature of the data when posting the question, I couldnt show much data but in my sample data HELP, the column runs from d1-d313 with most have value (companyid). Thus a specific firm could be linked to more than one firm. For instance a specific firm could be linked to just one while others two while others 20 etc. So firm with id 10001 is linked to more than two firms in the actual but couldnt show all as you requested i only post few sample for assessment and direction.Hence i have something like this below for data help CompanyID lpermno d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 10675 10001 8433 1723398 2070824 18195 620983 10002 576969 8433 959 10025 576969 1723398 9137 10028 2070824 18195 8433 12540 576969 Also please in the data help1, aside this variables, i have other variables price, market_returns in addition to CompanyID lpermno date volume stk_returns. I have tried several times trying to follow your codes but still getting it wrong. Please we are almost there and i seek for further direction to enable me apply on the main data as the codes work on the small sample data posted earlier. Thanks very much ChrisNZ for this great assistance.regards ejaa.
... View more