As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

# Talk:Sometimes One Needs an Option with Unusual Dates

Jump to: navigation, search

I believe I've made this code a little more flexible. You simply enter the DDMMM for when a Fiscal Year starts and everything else is built off that. The original code from the paper was tied to 06APR and the logic was built around that constant.

```    %let fystart=22JUN;
data fyds fqds fmds;
d=  day("&FYSTART.1950"d);
m=month("&FYSTART.1950"d);
q=  qtr("&FYSTART.1950"d);
do begin="&FYSTART.1950"d to "&FYSTART.2050"d-1;
if day(begin) eq d then do;
season=mod(month(begin) + (12-m), 12)+1;
end=intnx('month', begin, 1, 's')-1;
output fmds;
if mod(month(begin), 3)=mod(m, 3) then do;
season=floor((season-1)/3)+1;
end=intnx('month', begin, 3, 's')-1;
output fqds;
end;
if month(begin) eq m then do;
season=year(begin);
end=intnx('year', begin, 1, 's')-1;
output fyds;
end;
end;
end;
format begin end date9.;
drop d m q;
run;```

Richard, The code was only included as an example for creating intervalds datasets for certain British fiscal years. However, I totally agree that it could have been made more generalizable and appreciate your suggestion. I've modified the code to include a variant of your suggestion, namely to create a range of 100 years on either side of a given date. I.e.,

```%let FYstart=6APR2014;
%let FYlow=%sysfunc(catt(%sysfunc(day("&FYstart."d)),
%sysfunc(substr("&FYstart.",%sysfunc(anyalpha("&FYstart.")),3)),
%sysfunc(year("&FYstart."d))-100));
%let FYhi=%sysfunc(catt(%sysfunc(day("&FYstart."d)),
%sysfunc(substr("&FYstart.",%sysfunc(anyalpha("&FYstart.")),3)),
%sysfunc(year("&FYstart."d))+100));

data fyds fqds fmds;
d=  day("&FYstart."d);
m=month("&FYstart."d);
q=  qtr("&FYstart."d);
do begin="&FYlow."d to "&FYhi."d-1;
if day(begin) eq d then do;
season=mod(month(begin) + (12-m), 12)+1;
end=intnx('month', begin, 1, 's')-1;
output fmds;
if mod(month(begin), 3)=mod(m, 3) then do;
season=floor((season-1)/3)+1;
end=intnx('month', begin, 3, 's')-1;
output fqds;
end;
if month(begin) eq m then do;
season=year(begin);
end=intnx('year', begin, 1, 's')-1;
output fyds;
end;
end;
end;
format begin end date9.;
drop d m q;
run;```

--Art T 11:45, 6 October 2014 (CDT)