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.
Install Unix stata on Ubuntu in Windows Subsystem for Linuxl'm trying to install Stata on a unix kernel (unbuntu 20.10) installed on WSL on Windows 10 and i ge…
Nearstat Error MessageDear Statalist-Community, I am trying to calculate the distance between two datsets using their lat…
Connect VariablesHi everyone, hope you had a nice Christmas. I am having some Stata issues and i hope that someone …
Generating variables t-4 to 5Dear Statalisters, I am new to Stata and have been trying to generate the following variable. Varia…
Weakly balanced panelMy data looks like this. ----------------------- copy starting from the next line ------------------…
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