BookmarkSubscribeRSS Feed
Brandon16
Obsidian | Level 7
Hi,

Any idea how to create a date macro for the financial year please?

Currently we key in the dates as below

%let fin_start = 01APR2017;
%let fin_end = 01APR2018;

Thanks
5 REPLIES 5
Brandon16
Obsidian | Level 7
I want to take out the manual element of it so we are never required to update it, even when the financial year changes.
PeterClemmensen
Tourmaline | Level 20

Something like this?

 

data _null_;
   call symputx('fin_start', mdy(4, 1, year(today())));
   call symputx('fin_end', mdy(4, 1, year(today())+1));
run;

%put &fin_start. &fin_end.;
ballardw
Super User

How do you use that information? If the main purpose is to determine if a date value is in a given fiscal year you might get by with either a custom function or something similar to:

 

%macro myfiscalyear(date);
/* date must be a sas date value either 
  in the 'ddmmyyyy'd form or SAS numeric value of a date*/
%eval (%sysfunc(year(&date)) + %eval(%sysfunc(month(&date))> 4 ))
%mend;

%put Fiscal year of 23AUG2018 is %myfiscalyear('23AUG2018'd);


%put Fiscal year of 12345 is %myfiscalyear(12345);
Ksharp
Super User
%let fin_start = %sysfunc(intnx(year.4,%sysfunc(today()),0,b),date9.);
%let fin_end =  %sysfunc(intnx(year,"&fin_start"d,1,s),date9.);

%put &fin_start  &fin_end ;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 1662 views
  • 0 likes
  • 4 in conversation