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?
Related Posts with Drop all values other than month-end dates where the dates dont always end on standard monthend say there would be a value 27th May.
How to balance this datasetHi all I am having a hard time thinking about the best way to balance this dataset. The format is: …
age at first childHello, I am looking at childless men in the UK and I am using panel data which has 9 waves. childles…
Expand and Insert Observations to VariableHi all, Thanks in advance for any suggestions and supports! I am currently trying to expand a datas…
Using gsem with multiply imputed dataI am trying to fit a gsem model using multiply imputed data with multiple continuous factor dependen…
Rationale behind set seed/seedI have been coming across the "set seed" command while generating random numbers and while reporting…
Subscribe to:
Post Comments (Atom)
0 Response to Drop all values other than month-end dates where the dates dont always end on standard monthend say there would be a value 27th May.
Post a Comment