BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
amanjot_42
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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 

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

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 
amanjot_42
Fluorite | Level 6

Hi,

Thank you so much!

It worked perfectly.

 

Regards,

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 6553 views
  • 1 like
  • 2 in conversation