<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Who to create a fiscal year starting in October in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15526#M2735</link>
    <description>This is also an excellent solution. &lt;BR /&gt;
Thank you for sharing your SAS skills with me and hopefully others will profit as well.</description>
    <pubDate>Tue, 12 Oct 2010 12:41:52 GMT</pubDate>
    <dc:creator>coba</dc:creator>
    <dc:date>2010-10-12T12:41:52Z</dc:date>
    <item>
      <title>Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15515#M2724</link>
      <description>I searched in the forum but couldn't find the answer I am looking for.&lt;BR /&gt;
&lt;BR /&gt;
I have a data set containing information per quarter, for example, (format date is date7.), How do I create FY?&lt;BR /&gt;
&lt;BR /&gt;
type date       qtr  FY&lt;BR /&gt;
&lt;BR /&gt;
A     01oct08  4    2008/2009&lt;BR /&gt;
A     01jan09  1    2008/2009&lt;BR /&gt;
A     01apr09  2    2008/2009&lt;BR /&gt;
A     01jul09   3    2008/2009&lt;BR /&gt;
A     01oct09  1     2009/2010&lt;BR /&gt;
more lines .... and more columns&lt;BR /&gt;
&lt;BR /&gt;
thank you very much for your help

just to clarify I have not been able to create the field "FY" showing in the example, I would like to be able to group all my dates in this way&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: coba</description>
      <pubDate>Mon, 11 Oct 2010 19:23:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15515#M2724</guid>
      <dc:creator>coba</dc:creator>
      <dc:date>2010-10-11T19:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15516#M2725</link>
      <description>IF MONTH(DATE)&amp;gt;=10 then FY=YEAR(DATE)+1;</description>
      <pubDate>Mon, 11 Oct 2010 19:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15516#M2725</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-10-11T19:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15517#M2726</link>
      <description>Better to consider setting up a SAS PROC FORMAT using instream data or with a SAS input file (using CNTLIN= parameter) and define the calendar start-date of each fiscal period along with the display information that represents that fiscal period.  Here is an example:&lt;BR /&gt;
&lt;BR /&gt;
PROC FORMAT;&lt;BR /&gt;
VALUE FISCYRPD&lt;BR /&gt;
'01OCT2008'D = '1 2008/2009'&lt;BR /&gt;
'01NOV2008'D = '2 2008/2009'&lt;BR /&gt;
'01DEC2008'D = '3 2008/2009'&lt;BR /&gt;
OTHER = '?';&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
If needed (likely so), the "formatted" character-string field above can be parsed into two separate variables for sorting/display purposes.&lt;BR /&gt;
&lt;BR /&gt;
Or if the period always start on the 1st date, use INTNX to increment the date value up/back to the appropriate fiscal period-start-date and use a suitable output display FORMAT such as MMYY7. to display the resulting fiscal period-year.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Mon, 11 Oct 2010 20:23:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15517#M2726</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-10-11T20:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15518#M2727</link>
      <description>The only thing I look against is that it would become a long list... as I have more than 25 years data per quarter!&lt;BR /&gt;
Thank you very much for the display format.</description>
      <pubDate>Mon, 11 Oct 2010 20:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15518#M2727</guid>
      <dc:creator>coba</dc:creator>
      <dc:date>2010-10-11T20:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15519#M2728</link>
      <description>You may be able to come up with a SAS derivation algorithm to generate the "year/month" start-date for each fiscal period, otherwise, yes, you are face with defining each period and then start-date to end-date range.  Unless the "offset" is always some number of months forward/backward with a 1st of the month start-date, which can be derived programatically.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry &lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 12 Oct 2010 00:56:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15519#M2728</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-10-12T00:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15520#M2729</link>
      <description>this is my test data:&lt;BR /&gt;
&lt;BR /&gt;
type	date&lt;BR /&gt;
A	01-Oct-09&lt;BR /&gt;
A	01-Jan-10&lt;BR /&gt;
A	01-Apr-10&lt;BR /&gt;
A	01-Jul-10&lt;BR /&gt;
A	01-Oct-10&lt;BR /&gt;
A	01-Jan-11&lt;BR /&gt;
A	01-Apr-11&lt;BR /&gt;
A	01-Jul-11&lt;BR /&gt;
&lt;BR /&gt;
this is the test program&lt;BR /&gt;
&lt;BR /&gt;
data work.fy1 (KEEP=TYPE DATE FY);&lt;BR /&gt;
set work.fy;&lt;BR /&gt;
format FY crpyrf.;&lt;BR /&gt;
    YEAR=YEAR(DATE) ;&lt;BR /&gt;
    QTR=QTR(DATE) ;&lt;BR /&gt;
    MTH=MONTH(DATE);&lt;BR /&gt;
		if qtr=4 then FY=year; else FY=year-1 ;&lt;BR /&gt;
		if qtr=4 then qtr=1; else qtr=qtr+1;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
this is the results:&lt;BR /&gt;
type	date	FY&lt;BR /&gt;
A	01-Oct-09	09-Oct&lt;BR /&gt;
A	01-Jan-10	09-Oct&lt;BR /&gt;
A	01-Apr-10	09-Oct&lt;BR /&gt;
A	01-Jul-10	09-Oct&lt;BR /&gt;
A	01-Oct-10	2010&lt;BR /&gt;
A	01-Jan-11	2010&lt;BR /&gt;
A	01-Apr-11	2010&lt;BR /&gt;
A	01-Jul-11	2010&lt;BR /&gt;
 &lt;BR /&gt;
how do I manage to get this:&lt;BR /&gt;
type	date	FY&lt;BR /&gt;
A	01-Oct-09	09/10&lt;BR /&gt;
A	01-Jan-10	09/10&lt;BR /&gt;
A	01-Apr-10	09/10&lt;BR /&gt;
A	01-Jul-10	09/10&lt;BR /&gt;
A	01-Oct-10	10/11&lt;BR /&gt;
A	01-Jan-11	10/11&lt;BR /&gt;
A	01-Apr-11	10/11&lt;BR /&gt;
A	01-Jul-11	10/11&lt;BR /&gt;
&lt;BR /&gt;
thank you very much for your help</description>
      <pubDate>Tue, 12 Oct 2010 10:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15520#M2729</guid>
      <dc:creator>coba</dc:creator>
      <dc:date>2010-10-12T10:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15521#M2730</link>
      <description>Hi&lt;BR /&gt;
Nothing that Scott didn't suggest already - only a fully working code example.&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick&lt;BR /&gt;
&lt;BR /&gt;
data ctrl;&lt;BR /&gt;
  start='01oct1990'd;&lt;BR /&gt;
  retain fmtname 'FISCYRPD' type 'n';&lt;BR /&gt;
  do while (start lt '01oct2050'd);&lt;BR /&gt;
    end=intnx('month3',start,1,'b')-1;&lt;BR /&gt;
    label=put(start,date9.)||' '||cats(year(end+1)-1,'/',year(end+1));&lt;BR /&gt;
    output;&lt;BR /&gt;
    start=intnx('month3',start,1,'b');&lt;BR /&gt;
  end;&lt;BR /&gt;
&lt;BR /&gt;
  hlo='O';&lt;BR /&gt;
  label='** undefined FY **';&lt;BR /&gt;
  output;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc format library=work cntlin=ctrl;&lt;BR /&gt;
run;&lt;BR /&gt;
 &lt;BR /&gt;
data _null_;&lt;BR /&gt;
input type $ date anydtdte.;&lt;BR /&gt;
put date= FISCYRPD.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
A 01-Oct-09&lt;BR /&gt;
A 01-Jan-10&lt;BR /&gt;
A 01-Apr-10&lt;BR /&gt;
A 01-Jul-10&lt;BR /&gt;
A 01-Oct-10&lt;BR /&gt;
A 01-Jan-11&lt;BR /&gt;
A 01-Apr-11&lt;BR /&gt;
A 01-Jul-11&lt;BR /&gt;
;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 12 Oct 2010 11:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15521#M2730</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-10-12T11:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15522#M2731</link>
      <description>data fy;&lt;BR /&gt;
input type $ date :date9.;&lt;BR /&gt;
format date date9.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
A	01Oct09&lt;BR /&gt;
A	01Jan10&lt;BR /&gt;
A	01Apr10&lt;BR /&gt;
A	01Jul10&lt;BR /&gt;
A	01Oct10&lt;BR /&gt;
A	01Jan11&lt;BR /&gt;
A	01Apr11&lt;BR /&gt;
A	01Jul11&lt;BR /&gt;
A 01oct08&lt;BR /&gt;
A 01jan09 &lt;BR /&gt;
A 01apr09 &lt;BR /&gt;
A 01jul09 &lt;BR /&gt;
A 01oct09 &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data fy1;&lt;BR /&gt;
set fy;&lt;BR /&gt;
if MONTH(DATE) in (10, 11,12) then &lt;BR /&gt;
	do;&lt;BR /&gt;
		preyear = YEAR(DATE);&lt;BR /&gt;
		postyear = YEAR(DATE) + 1;&lt;BR /&gt;
		fiscal = compbl(preyear||"/"||postyear);&lt;BR /&gt;
		if qtr(date) = 4 then qtr = 1;&lt;BR /&gt;
	end;&lt;BR /&gt;
else if MONTH(DATE) not in (10, 11,12) then &lt;BR /&gt;
	do;&lt;BR /&gt;
		preyear = YEAR(DATE) - 1;&lt;BR /&gt;
		postyear = YEAR(DATE);&lt;BR /&gt;
		fiscal = compbl(preyear||"/"||postyear);&lt;BR /&gt;
		qtr = qtr(date) + 1; &lt;BR /&gt;
	end;&lt;BR /&gt;
	drop P:;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
This way you can get what u r looking out... i m not sure whether you require qtr, but i have calculated it.&lt;BR /&gt;
&lt;BR /&gt;
do let me know in case you require anything else.</description>
      <pubDate>Tue, 12 Oct 2010 11:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15522#M2731</guid>
      <dc:creator>Sunny</dc:creator>
      <dc:date>2010-10-12T11:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15523#M2732</link>
      <description>Thank you very much Sunny for your solution, specially now that my SAS skills did not allow me to get this solution.</description>
      <pubDate>Tue, 12 Oct 2010 11:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15523#M2732</guid>
      <dc:creator>coba</dc:creator>
      <dc:date>2010-10-12T11:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15524#M2733</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
Sorry to insist here a bit but I believe that using a format is a more versatile approach.&lt;BR /&gt;
&lt;BR /&gt;
Such FY categories tend to be needed over and over again for grouping and reports. That's why I think it's better to use a format which has to be created once instead of re-calculating everything over and over again.&lt;BR /&gt;
&lt;BR /&gt;
You can store a format in a permanent catalogue - also in one which is always available when you start SAS.&lt;BR /&gt;
&lt;BR /&gt;
Just to give you an idea of how to use a format:&lt;BR /&gt;
&lt;BR /&gt;
/* create a format for FY */&lt;BR /&gt;
data ctrl;&lt;BR /&gt;
start='01oct1990'd;&lt;BR /&gt;
retain fmtname 'FISCYRPD' type 'n';&lt;BR /&gt;
do while (start lt '01oct2050'd);&lt;BR /&gt;
end=intnx('month3',start,1,'b')-1;&lt;BR /&gt;
label=put(start,date9.)||' '||cats(year(end+1)-1,'/',year(end+1));&lt;BR /&gt;
output;&lt;BR /&gt;
start=intnx('month3',start,1,'b');&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
hlo='O';&lt;BR /&gt;
label='** undefined FY **';&lt;BR /&gt;
output;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc format library=work cntlin=ctrl;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* source data */&lt;BR /&gt;
data have;&lt;BR /&gt;
input type $ date anydtdte.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
A 01-Oct-09&lt;BR /&gt;
A 01-Jan-10&lt;BR /&gt;
A 01-Apr-10&lt;BR /&gt;
A 01-Jul-10&lt;BR /&gt;
A 01-Oct-10&lt;BR /&gt;
A 01-Jan-11&lt;BR /&gt;
A 01-Apr-11&lt;BR /&gt;
A 01-Jul-11&lt;BR /&gt;
;&lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
/* print source using FY format */&lt;BR /&gt;
title 'format applied on existing date var';&lt;BR /&gt;
proc print data=have;&lt;BR /&gt;
format date FISCYRPD.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* add character var containing fiscal year string */&lt;BR /&gt;
data want;&lt;BR /&gt;
  set have;&lt;BR /&gt;
  FY=put(date,FISCYRPD.);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
title 'additional var';&lt;BR /&gt;
proc print data=want;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Tue, 12 Oct 2010 12:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15524#M2733</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-10-12T12:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15525#M2734</link>
      <description>Consider using the SAS date functions.  INTNX can find the start date of the fiscal year, using a shifted interval.  Then fiscal year quarter can be determined with INTCK.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data test;&lt;BR /&gt;
   input type:$1. date:date.;&lt;BR /&gt;
   fy0 = intnx('year.10',date,0,'B'); *start date of fiscal year;&lt;BR /&gt;
   length fy $9;&lt;BR /&gt;
   fy   = catx('/',year(fy0),year(fy0)+1);&lt;BR /&gt;
   fyQT = intck('QTR',fy0,date)+1;&lt;BR /&gt;
   format date date. fy0 date.;&lt;BR /&gt;
   cards;&lt;BR /&gt;
A 01oct08&lt;BR /&gt;
A 01jan09&lt;BR /&gt;
A 01apr09&lt;BR /&gt;
A 01jul09&lt;BR /&gt;
A 01oct09&lt;BR /&gt;
B 10oct09&lt;BR /&gt;
B 23jan10&lt;BR /&gt;
B 14apr10&lt;BR /&gt;
B 04jul10&lt;BR /&gt;
B 16Oct10&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   by type;&lt;BR /&gt;
   id type;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
To produce this which I think is what the OP wanted.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;B&gt;type     date        fy0         fy        fyQ&lt;BR /&gt;
&lt;BR /&gt;
 A      01OCT08    01OCT08    2008/2009      1&lt;BR /&gt;
        01JAN09    01OCT08    2008/2009      2&lt;BR /&gt;
        01APR09    01OCT08    2008/2009      3&lt;BR /&gt;
        01JUL09    01OCT08    2008/2009      4&lt;BR /&gt;
        01OCT09    01OCT09    2009/2010      1&lt;BR /&gt;
&lt;BR /&gt;
 B      10OCT09    01OCT09    2009/2010      1&lt;BR /&gt;
        23JAN10    01OCT09    2009/2010      2&lt;BR /&gt;
        14APR10    01OCT09    2009/2010      3&lt;BR /&gt;
        04JUL10    01OCT09    2009/2010      4&lt;BR /&gt;
        16OCT10    01OCT10    2010/2011      1&lt;/B&gt;[/pre]</description>
      <pubDate>Tue, 12 Oct 2010 12:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15525#M2734</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-10-12T12:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15526#M2735</link>
      <description>This is also an excellent solution. &lt;BR /&gt;
Thank you for sharing your SAS skills with me and hopefully others will profit as well.</description>
      <pubDate>Tue, 12 Oct 2010 12:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15526#M2735</guid>
      <dc:creator>coba</dc:creator>
      <dc:date>2010-10-12T12:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Who to create a fiscal year starting in October</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15527#M2736</link>
      <description>Well.. see how many ways are there to solve a single problem. Thanks a lot for increasing my sas skills...</description>
      <pubDate>Tue, 12 Oct 2010 17:38:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Who-to-create-a-fiscal-year-starting-in-October/m-p/15527#M2736</guid>
      <dc:creator>Sunny</dc:creator>
      <dc:date>2010-10-12T17:38:57Z</dc:date>
    </item>
  </channel>
</rss>

