Hi,
I am trying to create a new column for the respective fiscal year for every date. The fiscal year starts from 1st April and ends on 31st March every year. I have daily data, and I want to create a new column for fiscal years (ending).
Firm ID date fiscal_year(desired)
11 28/06/2010 2011
12 25/02/2016 2016
13 02/04/2018 2019
14 09/12/2019 2020
Regards,
Amanjot
Try this
data have;
input FirmID date :ddmmyy10.;
format date ddmmyy10.;
datalines;
11 28/06/2010
12 25/02/2016
13 02/04/2018
14 09/12/2019
;
data want;
set have;
FiscalYear = year(intnx("year.4", date, 0, "e"));
run;
Result:
FirmID date FiscalYear 11 28/06/2010 2011 12 25/02/2016 2016 13 02/04/2018 2019 14 09/12/2019 2020
Try this
data have;
input FirmID date :ddmmyy10.;
format date ddmmyy10.;
datalines;
11 28/06/2010
12 25/02/2016
13 02/04/2018
14 09/12/2019
;
data want;
set have;
FiscalYear = year(intnx("year.4", date, 0, "e"));
run;
Result:
FirmID date FiscalYear 11 28/06/2010 2011 12 25/02/2016 2016 13 02/04/2018 2019 14 09/12/2019 2020
Hi,
Thank you so much!
It worked perfectly.
Regards,
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.