Hello,
I am trying to copy only the year from a column with dates in the format of ddmmyyyy into a new column. The existing date column in the format ddmmyyyy is called GSGiftDate.
Lets call this new column "fiscal_year".
However, I cannot simply use the gen fiscal_year = year(GSGiftDate) command. This command works for copying the same year as the column with the full ddmmyyyy date, but the fiscal year depends on the day and month range as well.
Example: A fiscal year in the way I'm using it is defined as July 1st to June 30th (7/1 - 6/30).
7/1/2013 to 6/30/2014 is Fiscal Year 2014
7/1/2014 to 6/30/2015 is Fiscal Year 2015
etc.
How do I give Stata a date range in which it knows to assign the second year in the range 7/1/yyyy - 6/30/yyyy+1 to this new fiscal_year variable? (For instance in range 7/1/2013-6/30/2014, fiscal_year would receive the value of 2014.)
Thank you
I am trying to copy only the year from a column with dates in the format of ddmmyyyy into a new column. The existing date column in the format ddmmyyyy is called GSGiftDate.
Lets call this new column "fiscal_year".
However, I cannot simply use the gen fiscal_year = year(GSGiftDate) command. This command works for copying the same year as the column with the full ddmmyyyy date, but the fiscal year depends on the day and month range as well.
Example: A fiscal year in the way I'm using it is defined as July 1st to June 30th (7/1 - 6/30).
7/1/2013 to 6/30/2014 is Fiscal Year 2014
7/1/2014 to 6/30/2015 is Fiscal Year 2015
etc.
How do I give Stata a date range in which it knows to assign the second year in the range 7/1/yyyy - 6/30/yyyy+1 to this new fiscal_year variable? (For instance in range 7/1/2013-6/30/2014, fiscal_year would receive the value of 2014.)
Thank you
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long PPidm int GSGiftDate double GIFTSPAYMENTS 70004539 15487 1925 70004539 15496 40 70004539 15630 125 70004546 17118 88 70004546 18210 45 70004546 18574 45 70004546 18911 45 70004546 19333 45 70004546 19737 45 70004546 20645 75 70004546 21013 75 70004546 21063 100 70004547 20863 20 70004591 20478 50 70004605 19415 100 end format %td GSGiftDate
Comment