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,

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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