I have converted a string variable called last_activity containing dates into a date formatted variable called last_activity_year using the following codes:
Code:
gen last_activity2 = date(last_activity, "MDY") format %td last_activity2 gen last_activity_year = year(last_activity2)
Code:
balance last_activity2 11.38 08jun1965 1602.94 17aug1965 1200 . 17aug1965 12.45 17jan1966 9.07 11apr1967 48.83 25aug1967 9144.33 25sep1967 46.48 31oct1967 38.04 19dec1967 40 . 19dec1967
Code:
38.04+40 = 78.04
Code:
gen last_activity_my=string(month(last_activity2), "%02.0f")+"_"+string(year(last_activity2)) preserve collapse (sum) monthly_balance = balance, by(last_activity_my)
0 Response to Summation by month + year
Post a Comment