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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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