<?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: Converting Ethiopian dates to SAS dates and then back to Ethiopian dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/451349#M113762</link>
    <description>&lt;P&gt;This aroused my curiosity.&lt;/P&gt;
&lt;P&gt;Here is a program that should create the correct Ethiopian date fields and the corresponding &lt;SPAN&gt;Gregorian&amp;nbsp;&lt;/SPAN&gt;date.&lt;/P&gt;
&lt;P&gt;Under your control. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[Edited: Gregorian, not Julian obviously. Brain fade... Sigh... ]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data CAL;
  DAY=0; MONTH=1; YEAR=1990;
  format GREGORIAN date9.;
  do GREGORIAN='11sep1997'd  to '12dec2028'd;
    DAY+1;
    %* new month ;
    if DAY=31 then do;                                        
      DAY=1;
      MONTH+1; 
    end;
    %* new year ;
    else if DAY=6 and MONTH=13 and mod(YEAR-1987,4) then do;  
      DAY=1;
      MONTH=1; 
      YEAR+1;
    end;
    %* new leap year;
    else if DAY=7 and MONTH=13 then do;                       
      DAY=1;
      MONTH=1; 
      YEAR+1;
    end;
    output;
  end;
run;             

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="263"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;DAY&lt;/TD&gt;
&lt;TD width="64"&gt;MONTH&lt;/TD&gt;
&lt;TD width="64"&gt;YEAR&lt;/TD&gt;
&lt;TD width="71"&gt;GREGORIAN&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;23&lt;/TD&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;2010&lt;/TD&gt;
&lt;TD&gt;01Apr2018&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;24&lt;/TD&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;2010&lt;/TD&gt;
&lt;TD&gt;02Apr2018&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;25&lt;/TD&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;2010&lt;/TD&gt;
&lt;TD&gt;03Apr2018&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;26&lt;/TD&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;2010&lt;/TD&gt;
&lt;TD&gt;04Apr2018&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Apr 2018 02:34:14 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-04-05T02:34:14Z</dc:date>
    <item>
      <title>Converting Ethiopian dates to SAS dates and then back to Ethiopian dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/447979#M112621</link>
      <description>&lt;P&gt;I'd like to find code that takes Ethiopian dates dd/mm/yyyy and converts them into Gregorian dates, any format is fine.&lt;/P&gt;&lt;P&gt;I then need to add a number of days to the Gregorian date and then convert that new date back to a new Ethiopian date.&lt;/P&gt;&lt;P&gt;While this might sound easy, it's not because the Ethiopian calendar has 12 months of 30 days and a 13th month of 5 or 6&lt;/P&gt;&lt;P&gt;days depending on where leap year falls. Does anyone have experience with this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 22:03:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/447979#M112621</guid>
      <dc:creator>mnflower</dc:creator>
      <dc:date>2018-03-22T22:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Ethiopian dates to SAS dates and then back to Ethiopian dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/447980#M112622</link>
      <description>&lt;P&gt;Are the years the same?&lt;BR /&gt;&lt;BR /&gt;If so, take your Ethiopian date and do some math to get the number of days in the year,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assume: dd/mm/yy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you have 05/04/2018&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the same as 5+4*30 = &lt;STRONG&gt;&lt;FONT color="#800000"&gt;125&lt;/FONT&gt;&lt;/STRONG&gt; days in 2018&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then convert that to a SAS date using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS_DATE = intnx('day', '01Jan2018'd, &lt;FONT color="#800000"&gt;&lt;STRONG&gt;125&lt;/STRONG&gt;&lt;/FONT&gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need further assistance, please post some sample data and the expected output so we can test it. Please post data as text.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200206"&gt;@mnflower&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'd like to find code that takes Ethiopian dates dd/mm/yyyy and converts them into Gregorian dates, any format is fine.&lt;/P&gt;
&lt;P&gt;I then need to add a number of days to the Gregorian date and then convert that new date back to a new Ethiopian date.&lt;/P&gt;
&lt;P&gt;While this might sound easy, it's not because the Ethiopian calendar has 12 months of 30 days and a 13th month of 5 or 6&lt;/P&gt;
&lt;P&gt;days depending on where leap year falls. Does anyone have experience with this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 22:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/447980#M112622</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-22T22:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Ethiopian dates to SAS dates and then back to Ethiopian dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/448072#M112668</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, I think it's more complicated than that. Ethiopia has a very peculiar calendar: &lt;A href="https://en.wikipedia.org/wiki/Ethiopian_calendar" target="_blank"&gt;https://en.wikipedia.org/wiki/Ethiopian_calendar&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The year starts at September 11 (Gregorian) in the current era (between 1900 and 2100)&lt;/P&gt;
&lt;P&gt;For a successful conversion, we need to accomodate that and the different count in years.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 07:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/448072#M112668</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-23T07:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Ethiopian dates to SAS dates and then back to Ethiopian dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/448177#M112718</link>
      <description>&lt;P&gt;Wouldn't it still be the same math, but then subtract the number of days to Sept 11?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 14:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/448177#M112718</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-23T14:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Ethiopian dates to SAS dates and then back to Ethiopian dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/451252#M113731</link>
      <description>&lt;P&gt;Thank you for the replies. This is the first time I've posted anything and I'm impressed with the&lt;/P&gt;&lt;P&gt;willingness to help. I've chased down several rabbit holes and your responses reinforce how&lt;/P&gt;&lt;P&gt;complicated a mathematical approach to this problem would be for someone like me who is not&lt;/P&gt;&lt;P&gt;very skilled in this area. I changed by approach. My project only needs 10 years worth of Ethiopian&lt;/P&gt;&lt;P&gt;dates with matching Gregorian dates. I created a table using an online date converter (one date&lt;/P&gt;&lt;P&gt;at a time) of where Ethiopian leap years fell and Gregorian leap years fell. Then I started with the&lt;/P&gt;&lt;P&gt;first Ethiopian date of our data collection period and found the matching Gregorian date. Then I&lt;/P&gt;&lt;P&gt;created one year's worth of corresponding dates. I use a very flexible editor so this took me about&lt;/P&gt;&lt;P&gt;and hour. I allowed for 12 months of 30 days and 1 month of 5 days (6 if leap year) for the Ethiopian&lt;/P&gt;&lt;P&gt;side and the regular Gregorian months with their unique number of days for the Gregorian side. As&lt;/P&gt;&lt;P&gt;I built each additional year, I watched for leap years on both sides. The whole process took me about&lt;/P&gt;&lt;P&gt;5 hours including checking. I created several thousand records in a text file of two variables, an Ethiopian&lt;/P&gt;&lt;P&gt;date and a Gregorian date. I have that data available as a SAS data file that I can sort depending on&lt;/P&gt;&lt;P&gt;which date I need to match. This allows me to have the Ethiopian date AND the Gregorian date&lt;/P&gt;&lt;P&gt;defined as a SAS date in my code. I can add the number of days I want to the Gregorian date and&lt;/P&gt;&lt;P&gt;then look up the Ethiopian date that matches the Gregorian date. While I know this is not a very&lt;/P&gt;&lt;P&gt;elegant solution, it's working for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 18:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/451252#M113731</guid>
      <dc:creator>mnflower</dc:creator>
      <dc:date>2018-04-04T18:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Ethiopian dates to SAS dates and then back to Ethiopian dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/451346#M113759</link>
      <description>&lt;P&gt;Well done!&lt;/P&gt;
&lt;P&gt;If you want, you can now create formats using your values to ease the conversion process back and forth.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 23:07:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/451346#M113759</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-04-04T23:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Ethiopian dates to SAS dates and then back to Ethiopian dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/451349#M113762</link>
      <description>&lt;P&gt;This aroused my curiosity.&lt;/P&gt;
&lt;P&gt;Here is a program that should create the correct Ethiopian date fields and the corresponding &lt;SPAN&gt;Gregorian&amp;nbsp;&lt;/SPAN&gt;date.&lt;/P&gt;
&lt;P&gt;Under your control. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[Edited: Gregorian, not Julian obviously. Brain fade... Sigh... ]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data CAL;
  DAY=0; MONTH=1; YEAR=1990;
  format GREGORIAN date9.;
  do GREGORIAN='11sep1997'd  to '12dec2028'd;
    DAY+1;
    %* new month ;
    if DAY=31 then do;                                        
      DAY=1;
      MONTH+1; 
    end;
    %* new year ;
    else if DAY=6 and MONTH=13 and mod(YEAR-1987,4) then do;  
      DAY=1;
      MONTH=1; 
      YEAR+1;
    end;
    %* new leap year;
    else if DAY=7 and MONTH=13 then do;                       
      DAY=1;
      MONTH=1; 
      YEAR+1;
    end;
    output;
  end;
run;             

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="263"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;DAY&lt;/TD&gt;
&lt;TD width="64"&gt;MONTH&lt;/TD&gt;
&lt;TD width="64"&gt;YEAR&lt;/TD&gt;
&lt;TD width="71"&gt;GREGORIAN&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;23&lt;/TD&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;2010&lt;/TD&gt;
&lt;TD&gt;01Apr2018&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;24&lt;/TD&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;2010&lt;/TD&gt;
&lt;TD&gt;02Apr2018&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;25&lt;/TD&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;2010&lt;/TD&gt;
&lt;TD&gt;03Apr2018&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;26&lt;/TD&gt;
&lt;TD&gt;7&lt;/TD&gt;
&lt;TD&gt;2010&lt;/TD&gt;
&lt;TD&gt;04Apr2018&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 02:34:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/451349#M113762</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-04-05T02:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Ethiopian dates to SAS dates and then back to Ethiopian dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/451362#M113770</link>
      <description>&lt;P&gt;This may or may not be overkill but, combined with the code you've already been provided, here is a way to formalize those dates:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/Sometimes_One_Needs_an_Option_with_Unusual_Dates" target="_blank"&gt;http://www.sascommunity.org/wiki/Sometimes_One_Needs_an_Option_with_Unusual_Dates&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a paper that a group of us wrote, a couple of years ago, to make it easier to adapt any type of date within SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 01:08:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/451362#M113770</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-04-05T01:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Ethiopian dates to SAS dates and then back to Ethiopian dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/451369#M113772</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;sascommunity.org will be missed.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 02:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Ethiopian-dates-to-SAS-dates-and-then-back-to/m-p/451369#M113772</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-04-05T02:00:43Z</dc:date>
    </item>
  </channel>
</rss>

