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,
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: