<?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: fiscal year manipulation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/fiscal-year-manipulation/m-p/691351#M210404</link>
    <description>&lt;P&gt;Compress knows nothing of the formats involved&lt;/P&gt;
&lt;P&gt;so when you use:&lt;/P&gt;
&lt;PRE&gt;fiscal_year = intnx('YEAR.4',date,0);
format combine2 $20.;
combine2 = compress(fiscal_year||"wrong");&lt;/PRE&gt;
&lt;P&gt;Then compress is using the numeric value of the date fiscal_year. If you want a character function, such as Compress, to use the "proper" value then you need to explicitly convert the number to character.&lt;/P&gt;
&lt;PRE&gt;combine2 = compress(put(fiscal_year, year4.)||"wrong");&lt;/PRE&gt;
&lt;P&gt;Now, for your&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I've looked extensively at this forum for how to convert (calendar) years into fiscal year format, but I'm having problems with the formatting and data manipulation of the fiscal years.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You do not provide any examples of the fiscal year rules or what you expect to get with "formatting".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For many purposes it may be sufficient to have a Fiscal Year variable. Which can usually be achieved by incrementing year of a date after a given date. For example the US Federal Fiscal year that changes in October:&lt;/P&gt;
&lt;PRE&gt;data example;
   date = '15OCT2020'd;
   calyear= year(date);
   FedFiscalYear = year(date)+(month(date) ge 10);
run;&lt;/PRE&gt;
&lt;P&gt;But details on what you need will help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Oct 2020 17:39:06 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-10-13T17:39:06Z</dc:date>
    <item>
      <title>fiscal year manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fiscal-year-manipulation/m-p/691347#M210401</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I've looked extensively at this forum for how to convert (calendar) years into fiscal year format, but I'm having problems with the formatting and data manipulation of the fiscal years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my code I can use the year function to get years, but this is calendar years:&lt;/P&gt;&lt;P&gt;&amp;nbsp;format calendar_year Best12.;&lt;BR /&gt;&amp;nbsp;calendar_year=compress(year(date));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then create a new variable called "combine" that just has the calendar_year with a "check" text:&lt;/P&gt;&lt;P&gt;format combine $20.&lt;BR /&gt;combine = compress(calendar_year||"check");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is what I want: "2019check" Note that I see the year displayed correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I try to convert my code into fiscal year, using what I learned from this forum, I don't get what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do the following:&lt;/P&gt;&lt;P&gt;format fiscal_year year. ;&lt;BR /&gt;fiscal_year = intnx('YEAR.4',date,0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I proc print fiscal_year, it displays correct e.g., 2019.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I try to create the combine2 variable as follows:&lt;/P&gt;&lt;P&gt;format combine2 $20.;&lt;BR /&gt;combine2 = compress(fiscal_year||"wrong");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My result is the SAS date format as follows: 1524wrong. I would like it to display as 2019wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 17:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fiscal-year-manipulation/m-p/691347#M210401</guid>
      <dc:creator>sharonlee</dc:creator>
      <dc:date>2020-10-13T17:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: fiscal year manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fiscal-year-manipulation/m-p/691351#M210404</link>
      <description>&lt;P&gt;Compress knows nothing of the formats involved&lt;/P&gt;
&lt;P&gt;so when you use:&lt;/P&gt;
&lt;PRE&gt;fiscal_year = intnx('YEAR.4',date,0);
format combine2 $20.;
combine2 = compress(fiscal_year||"wrong");&lt;/PRE&gt;
&lt;P&gt;Then compress is using the numeric value of the date fiscal_year. If you want a character function, such as Compress, to use the "proper" value then you need to explicitly convert the number to character.&lt;/P&gt;
&lt;PRE&gt;combine2 = compress(put(fiscal_year, year4.)||"wrong");&lt;/PRE&gt;
&lt;P&gt;Now, for your&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I've looked extensively at this forum for how to convert (calendar) years into fiscal year format, but I'm having problems with the formatting and data manipulation of the fiscal years.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You do not provide any examples of the fiscal year rules or what you expect to get with "formatting".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For many purposes it may be sufficient to have a Fiscal Year variable. Which can usually be achieved by incrementing year of a date after a given date. For example the US Federal Fiscal year that changes in October:&lt;/P&gt;
&lt;PRE&gt;data example;
   date = '15OCT2020'd;
   calyear= year(date);
   FedFiscalYear = year(date)+(month(date) ge 10);
run;&lt;/PRE&gt;
&lt;P&gt;But details on what you need will help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 17:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fiscal-year-manipulation/m-p/691351#M210404</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-13T17:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: fiscal year manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fiscal-year-manipulation/m-p/691354#M210407</link>
      <description>&lt;P&gt;&lt;STRONG&gt;fiscal_year&lt;/STRONG&gt; (the result of your INTNX function call) is a SAS &lt;EM&gt;date&lt;/EM&gt; value, not just a year value. You want &lt;STRONG&gt;fiscal_year&lt;/STRONG&gt; as a character value representing the year, just like the character value you built for &lt;STRONG&gt;calendar_year&lt;/STRONG&gt;. Try this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;&lt;BR /&gt;   format date mmddyy10. calendar_year fiscal_year best12. combine combine2 $20.;&lt;BR /&gt;   date='01jan2019'd;&lt;BR /&gt;   calendar_year= put(date,year4.);&lt;BR /&gt;   fiscal_year = put(intnx('YEAR.4',date,0),year4.);&lt;BR /&gt;   combine = cats(calendar_year,"check");&lt;BR /&gt;   combine2 = cats(fiscal_year,"check");&lt;BR /&gt;   output;&lt;BR /&gt;   date='01jun2019'd;&lt;BR /&gt;   calendar_year= put(date,year4.);&lt;BR /&gt;   fiscal_year = put(intnx('YEAR.4',date,0),year4.);&lt;BR /&gt;   combine = cats(calendar_year,"check");&lt;BR /&gt;   combine2 = cats(fiscal_year,"check");&lt;BR /&gt;   output;&lt;BR /&gt;run;&lt;BR /&gt;proc print;&lt;BR /&gt;run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is the result:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;TABLE width="478"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="38"&gt;Obs&lt;/TD&gt;
&lt;TD width="69"&gt;date&lt;/TD&gt;
&lt;TD width="114"&gt;calendar_year&lt;/TD&gt;
&lt;TD width="89"&gt;fiscal_year&lt;/TD&gt;
&lt;TD width="84"&gt;combine&lt;/TD&gt;
&lt;TD width="84"&gt;combine2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="38"&gt;1&lt;/TD&gt;
&lt;TD width="69"&gt;1/1/2019&lt;/TD&gt;
&lt;TD width="114"&gt;2019&lt;/TD&gt;
&lt;TD width="89"&gt;2018&lt;/TD&gt;
&lt;TD width="84"&gt;2019check&lt;/TD&gt;
&lt;TD width="84"&gt;2018check&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="38"&gt;2&lt;/TD&gt;
&lt;TD width="69"&gt;6/1/2019&lt;/TD&gt;
&lt;TD width="114"&gt;2019&lt;/TD&gt;
&lt;TD width="89"&gt;2019&lt;/TD&gt;
&lt;TD width="84"&gt;2019check&lt;/TD&gt;
&lt;TD width="84"&gt;2019check&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 17:54:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fiscal-year-manipulation/m-p/691354#M210407</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2020-10-13T17:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: fiscal year manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fiscal-year-manipulation/m-p/691376#M210418</link>
      <description>&lt;P&gt;Thank you for reminding me the importance of using the "put" statement!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 19:51:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fiscal-year-manipulation/m-p/691376#M210418</guid>
      <dc:creator>sharonlee</dc:creator>
      <dc:date>2020-10-13T19:51:46Z</dc:date>
    </item>
  </channel>
</rss>

