Hi Salma,
Using Nick's code, now you can collapse the daily data to a yearly data, add 1 year to the collapsed year variable and merge as follows:
Abraham
Using Nick's code, now you can collapse the daily data to a yearly data, add 1 year to the collapsed year variable and merge as follows:
Code:
egen SD = sd(ret), by(permno yr) collapse (mean) SD, by(permno yr) replace yr = yr + 1 save SD.dta, replace use masterdata.dta, clear merge m:1 permno yr using SD.dta
Comment