Hi,

I have a file with a date column and 5 other daily return columns. File attached.
I use the below code to get monthly return :

import delimited "C:\Users\Aakash\Desktop\AIA\Clean Data\AQR_BAB_Factors.csv", case(preserve)
gen trdate = date(Date,"MDY")
format %td trdate
tsset trdate
ascol AQR_BAB_Equity_Global, returns(simple) keep(all) tomonth gen(AQR_BAB_MonthlyGlobal)
drop month_id
ascol AQR_BAB_Equity_Global_Ex_USA, returns(simple) keep(all) tomonth gen(AQR_BAB_MonthlyGlobalExUSA)
drop month_id
ascol AQR_BAB_Equity_Europe, returns(simple) keep(all) tomonth gen(AQR_BAB_MonthlyEurope)
drop month_id
ascol AQR_BAB_Equity_NorthAmerica, returns(simple) keep(all) tomonth gen(AQR_BAB_MonthlyNorthAmerica)
drop month_id
ascol AQR_BAB_Equity_Pacific, returns(simple) keep(all) tomonth gen(AQR_BAB_MonthlyPacific)

Now I need only the monthend dates. I need all last day of month even if its not standard month-end date.
How do I do that ?

I tried the below :

gen long first_of_next_month = dofm(mofd(trdate)+1)
keep if trdate + 1 == first_of_next_month

But this returns only standard month-end dates and deletes all other data.
Could someone help?