0
$\begingroup$

I have merged Compustat and CRSP but I have been stuck on this issue for a long time.

I wanted to create the variables

  • RET : contemporaneous annual stock returns calculating using CRSP monthly return data, and
  • RET2 : buy-and hold monthly returns for 12 months ending three months after fiscal-year-end

So I could use these variables in a regression for a panel data sample of gvkey fyear

MAIN FILE: compustat

compustat

STOCK RETURN DATA

Stock_Return_Data

The last thing I tried was this:

crsp <- data.crsp.cln %>% group_by(PERMNO) %>%  mutate(ret.12t2 = (lag(retadj.1mn,1)+1)*(lag(retadj.1mn,2)+1)*(lag(retadj.1mn,3)+1)*(lag(retadj.1mn,4)+1)*
                                   (lag(retadj.1mn,5)+1)*(lag(retadj.1mn,6)+1)*(lag(retadj.1mn,7)+1)*(lag(retadj.1mn,8)+1)*
                                   (lag(retadj.1mn,9)+1)*(lag(retadj.1mn,10)+1)*(lag(retadj.1mn,11)+1)-1,)

crsp <-crsp %>% group_by(year(Date), PERMNO) %>% select(Date, PERMNO, retx, retadj.1mn, ret.12t2)
```
$\endgroup$
2
  • $\begingroup$ What exactly is your question? How to create these variables? Can you give us a sample of your data? $\endgroup$
    – Bob Jansen
    Jan 5, 2021 at 19:19
  • $\begingroup$ Thank you so much. Yes, I will explain better have my main data set with those firms that had a cyberattack by "gvkey and fyear" and variables for each firm and year e.g. total assets, etc... and CRSP is a data base that is monthly so the return is for every month. So i assume I convert it into an annual data base before merging them toguether $\endgroup$ Jan 6, 2021 at 1:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.