Hello everyone!
I would really appreciate help on the below.
I would like to find the difference between one variable named "Birthyear_C" (with e.g. 1985m5) and 2019m1 which is Jan 2019 and in doing so generate the number of months and round it up for my analysis of an event study model. I have provided my simple command and data below. The error reads "2019m1 invalid name". I have gone through help datetime but still can't figure out how to transform the 2019m1 to a Stata "month count" format. 21550 for example represents the count of days from 1.1.1960 to 1.1.2019 but I only want to calculate the months since my "Birthyear_C" only has month and year.
I would really appreciate help on the below.
I would like to find the difference between one variable named "Birthyear_C" (with e.g. 1985m5) and 2019m1 which is Jan 2019 and in doing so generate the number of months and round it up for my analysis of an event study model. I have provided my simple command and data below. The error reads "2019m1 invalid name". I have gone through help datetime but still can't figure out how to transform the 2019m1 to a Stata "month count" format. 21550 for example represents the count of days from 1.1.1960 to 1.1.2019 but I only want to calculate the months since my "Birthyear_C" only has month and year.
Code:
g montht = round(birthyear_C-2019m1)
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte b1_ int b2_ float birthyear_C 5 -29 328 7 -29 330 9 -29 332 10 -29 333 11 -29 334 11 -29 334 12 -29 335 12 -29 335 1 -28 336 2 -28 337 2 -28 337 2 -28 337 2 -28 337 2 -28 337 2 -28 337 2 -28 337 3 -28 338 3 -28 338 3 -28 338 4 -28 339 5 -28 340 5 -28 340 6 -28 341 7 -28 342 7 -28 342 7 -28 342 7 -28 342 7 -28 342 7 -28 342 8 -28 343 8 -28 343 8 -28 343 8 -28 343 8 -28 343 8 -28 343 8 -28 343 9 -28 344 10 -28 345 10 -28 345 10 -28 345 11 -28 346 11 -28 346 12 -28 347 12 -28 347 1 -27 348 1 -27 348 2 -27 349 2 -27 349 2 -27 349 2 -27 349 2 -27 349 3 -27 350 3 -27 350 3 -27 350 4 -27 351 4 -27 351 4 -27 351 4 -27 351 5 -27 352 5 -27 352 5 -27 352 5 -27 352 6 -27 353 6 -27 353 6 -27 353 6 -27 353 6 -27 353 7 -27 354 7 -27 354 7 -27 354 7 -27 354 7 -27 354 8 -27 355 8 -27 355 8 -27 355 8 -27 355 8 -27 355 8 -27 355 8 -27 355 9 -27 356 9 -27 356 9 -27 356 10 -27 357 10 -27 357 10 -27 357 10 -27 357 10 -27 357 11 -27 358 11 -27 358 11 -27 358 11 -27 358 11 -27 358 11 -27 358 11 -27 358 12 -27 359 12 -27 359 12 -27 359 12 -27 359 12 -27 359 12 -27 359 end format %tm birthyear_C
Comment