<?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: Coding with fiscal year ends in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Coding-with-fiscal-year-ends/m-p/405257#M279104</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;It worked, thank God!&amp;nbsp; Here's the code:&lt;/P&gt;
&lt;P&gt;data Etr.restatement1;&lt;BR /&gt;set Etr.restatement;&lt;BR /&gt;rpb = restated_period_begin;&lt;BR /&gt;rpe = restated_period_ended;&lt;BR /&gt;RstateDays = (Datdif (rpb, rpe, 'act/act'))+1;&lt;BR /&gt;if month(restated_period_begin) le fiscal_month_end then y1 = year(restated_period_begin);&lt;BR /&gt;else y1 = year(restated_period_begin) + 1;&lt;BR /&gt;if month(restated_period_ended) le fiscal_month_end then y2 = year(restated_period_ended);&lt;BR /&gt;else y2 = year(restated_period_ended) + 1;&lt;BR /&gt;if month(disclosure_date) le fiscal_month_end then y3 = year(disclosure_date);&lt;BR /&gt;else y3 = year(disclosure_date) + 1;&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt;data Etr.restatement1a;&lt;BR /&gt;set Etr.restatement1;&lt;BR /&gt;If RstateDays LT 350 then delete;&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt;data Etr.restatement2;&lt;BR /&gt;set Etr.restatement1a;&lt;BR /&gt;drop rpb;&lt;BR /&gt;drop rpe;&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt; proc sort data=Etr.restatement2 out=Etr.restatement2a;&lt;BR /&gt; by cik;&lt;BR /&gt; run;&lt;BR /&gt; &lt;BR /&gt; /*create observation for each year restated [include begin year and end year] */&lt;BR /&gt; data Etr.restatement3;&lt;BR /&gt; set Etr.restatement2a;&lt;BR /&gt; by cik;&lt;BR /&gt; if cik then do;&lt;BR /&gt; do fyear=y1 to y3;&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt; end;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;proc sort data= Etr.restatement3 out= Etr.restatement4 noduplicate; &lt;BR /&gt;by restatement_key cik fyear;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data Etr.restatement5;&lt;BR /&gt; set Etr.restatement4;&lt;BR /&gt; if y1 = fyear then FO=1;&lt;BR /&gt; else FO=0;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;data Etr.restatement6;&lt;BR /&gt; set Etr.restatement5;&lt;BR /&gt; if y3 = fyear then AD=1;&lt;BR /&gt; else AD=0;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;data Etr.restatement7;&lt;BR /&gt; set Etr.restatement6;&lt;BR /&gt; if y1 le fyear le y2 then AO=1;&lt;BR /&gt; else AO=0;&lt;BR /&gt; run;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Oct 2017 15:41:46 GMT</pubDate>
    <dc:creator>jjadall1</dc:creator>
    <dc:date>2017-10-18T15:41:46Z</dc:date>
    <item>
      <title>Coding with fiscal year ends</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-with-fiscal-year-ends/m-p/404896#M279103</link>
      <description>&lt;P&gt;Hello SAS Support Communities,&lt;/P&gt;
&lt;P&gt;Please see the code below.&amp;nbsp; For your information, cik in the code is a unique identifier for each company (e.g., Lowe's, Home Depot, etc.)&amp;nbsp; Let me give you an example of what I'm looking for.&amp;nbsp; Let's say a company has a 12/31 fiscal year-end.&amp;nbsp; There's a restatement that covers January 1, 2009 (rpb in the code below) through June 30, 2012 (rpe in the code below) that is disclosed on June 15, 2014.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like 3 versions of a categorical dependent variable in the same dataset as follows:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;One with a categorical dummy variable = 1 if restatement_key (identifier of each restatement (January 1, 2009 through June 30, 2012 in my example)) is in year 1 of the restatement.&amp;nbsp; That would be if first.restatement key then do, correct?&amp;nbsp; In my example, the only categorical dependent variable with a value of 1 would be fyear = 2009.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL start="2"&gt;
&lt;LI&gt;One with a categorical dummy variable = 1 if fyear is between y1 and y2.&amp;nbsp; In my example, the categorical dependent variable would have a value of 1 when fyear = 2009, 2010, 2011, and 2012.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL start="3"&gt;
&lt;LI&gt;One with a categorical dummy variable = 1 only in the year of disclosure.&amp;nbsp; In my example, the categorical dependent variable would have a value of 1 when fyear = 2014.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;data Etr.restatement1;&lt;BR /&gt;set Etr.restatement;&lt;BR /&gt;rpb = restated_period_begin;&lt;BR /&gt;rpe = restated_period_ended;&lt;BR /&gt;RstateDays = (Datdif (rpb, rpe, 'act/act'))+1;&lt;BR /&gt;y1 = year(restated_period_begin);&lt;BR /&gt;y2 = year(restated_period_ended);&lt;BR /&gt;y3 = year(disclosure_date);&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt;data Etr.restatement1a;&lt;BR /&gt;set Etr.restatement1;&lt;BR /&gt;If RstateDays LT 350 then delete;&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt;data Etr.restatement2;&lt;BR /&gt;set Etr.restatement1a;&lt;BR /&gt;drop rpb;&lt;BR /&gt;drop rpe;&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt; proc sort data=Etr.restatement2 out=Etr.restatement2a;&lt;BR /&gt; by cik;&lt;BR /&gt; run;&lt;BR /&gt; &lt;BR /&gt; /*create observation for each year restated [include begin year and end year] */&lt;BR /&gt; data Etr.restatement3;&lt;BR /&gt; set Etr.restatement2a;&lt;BR /&gt; by cik;&lt;BR /&gt; if cik then do;&lt;BR /&gt; do fyear=y1 to y3;&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt; end;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;proc sort data= Etr.restatement3 out= Etr.restatement4 noduplicate; &lt;BR /&gt;by restatement_key cik fyear;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data Etr.restatement5;&lt;BR /&gt; set Etr.restatement4;&lt;BR /&gt; if y1 = fyear then FO=1;&lt;BR /&gt; else FO=0;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;data Etr.restatement6;&lt;BR /&gt; set Etr.restatement5;&lt;BR /&gt; if y3 = fyear then AD=1;&lt;BR /&gt; else AD=0;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;data Etr.restatement7;&lt;BR /&gt; set Etr.restatement6;&lt;BR /&gt; if y1 le fyear le y2 then AO=1;&lt;BR /&gt; else AO=0;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was able to get the code to work IF a company has a 12/31 fiscal year-end.&amp;nbsp; The restatement5 dataset generates dependent variable #1 (FO).&amp;nbsp; The restatement6 dataset generates dependent variable #3 (AD).&amp;nbsp; The restatement7 dataset generates dependent variable #2 (AO).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A problem sometimes occurs when a company does NOT have a 12/31 fiscal year end.&amp;nbsp; Look at the attached restatement7 dataset.&amp;nbsp; Observations 1 through 6 are good.&amp;nbsp; However, look at observation 7 for example.&amp;nbsp; For dependent variable #1 (FO), the company has a fiscal year-end of 5/31 (fiscal_month_end column).&amp;nbsp; The restatement started on 7/1/2012.&amp;nbsp; Therefore, the first occurrence (FO) should be for the 2013 fiscal year (since 7/1/2012 is between 6/1/2012 and 5/31/2013).&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For dependent variable #2 (AO), look at observations 7 through 10.&amp;nbsp; Observation 7 should NOT have a value of 1 because the restatement period began 7/1/2012 (which is after the 5/31/2012 cutoff).&amp;nbsp; Observations 8 through 10 should have a value of 1 because of the following:&lt;/P&gt;
&lt;P&gt;Restatement covers a time in between 6/1/2012 and 5/31/2013 (2013 fiscal year)&lt;/P&gt;
&lt;P&gt;Restatement covers a time in between 6/1/2013 and 5/31/2014 (2014 fiscal year)&lt;/P&gt;
&lt;P&gt;Restatement covers a time in between 6/1/2014 and 5/31/2015 (2015 fiscal year)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For dependent variable #3 (AD), 6/29/2015 falls in between 6/1/2015 and 5/31/2016 (2016 fiscal year).&amp;nbsp; Therefore, observations 7 through 10 should all NOT have a value of 1.&amp;nbsp; An additional observation should be created (2016 fiscal year) and that observation should have a value of 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I update my code to include these issues?&amp;nbsp; The original dataset (restatement) is attached for you to work with.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;God bless, best regards, and thank you so much for your help,&lt;BR /&gt;Jadallah&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2017 17:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-with-fiscal-year-ends/m-p/404896#M279103</guid>
      <dc:creator>jjadall1</dc:creator>
      <dc:date>2017-10-17T17:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Coding with fiscal year ends</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-with-fiscal-year-ends/m-p/405257#M279104</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;It worked, thank God!&amp;nbsp; Here's the code:&lt;/P&gt;
&lt;P&gt;data Etr.restatement1;&lt;BR /&gt;set Etr.restatement;&lt;BR /&gt;rpb = restated_period_begin;&lt;BR /&gt;rpe = restated_period_ended;&lt;BR /&gt;RstateDays = (Datdif (rpb, rpe, 'act/act'))+1;&lt;BR /&gt;if month(restated_period_begin) le fiscal_month_end then y1 = year(restated_period_begin);&lt;BR /&gt;else y1 = year(restated_period_begin) + 1;&lt;BR /&gt;if month(restated_period_ended) le fiscal_month_end then y2 = year(restated_period_ended);&lt;BR /&gt;else y2 = year(restated_period_ended) + 1;&lt;BR /&gt;if month(disclosure_date) le fiscal_month_end then y3 = year(disclosure_date);&lt;BR /&gt;else y3 = year(disclosure_date) + 1;&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt;data Etr.restatement1a;&lt;BR /&gt;set Etr.restatement1;&lt;BR /&gt;If RstateDays LT 350 then delete;&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt;data Etr.restatement2;&lt;BR /&gt;set Etr.restatement1a;&lt;BR /&gt;drop rpb;&lt;BR /&gt;drop rpe;&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt; proc sort data=Etr.restatement2 out=Etr.restatement2a;&lt;BR /&gt; by cik;&lt;BR /&gt; run;&lt;BR /&gt; &lt;BR /&gt; /*create observation for each year restated [include begin year and end year] */&lt;BR /&gt; data Etr.restatement3;&lt;BR /&gt; set Etr.restatement2a;&lt;BR /&gt; by cik;&lt;BR /&gt; if cik then do;&lt;BR /&gt; do fyear=y1 to y3;&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt; end;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;proc sort data= Etr.restatement3 out= Etr.restatement4 noduplicate; &lt;BR /&gt;by restatement_key cik fyear;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data Etr.restatement5;&lt;BR /&gt; set Etr.restatement4;&lt;BR /&gt; if y1 = fyear then FO=1;&lt;BR /&gt; else FO=0;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;data Etr.restatement6;&lt;BR /&gt; set Etr.restatement5;&lt;BR /&gt; if y3 = fyear then AD=1;&lt;BR /&gt; else AD=0;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;data Etr.restatement7;&lt;BR /&gt; set Etr.restatement6;&lt;BR /&gt; if y1 le fyear le y2 then AO=1;&lt;BR /&gt; else AO=0;&lt;BR /&gt; run;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 15:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-with-fiscal-year-ends/m-p/405257#M279104</guid>
      <dc:creator>jjadall1</dc:creator>
      <dc:date>2017-10-18T15:41:46Z</dc:date>
    </item>
  </channel>
</rss>

