I'd like to find code that takes Ethiopian dates dd/mm/yyyy and converts them into Gregorian dates, any format is fine.
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.
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
days depending on where leap year falls. Does anyone have experience with this?
Are the years the same?
If so, take your Ethiopian date and do some math to get the number of days in the year,
Assume: dd/mm/yy
So if you have 05/04/2018
This is the same as 5+4*30 = 125 days in 2018
Then convert that to a SAS date using:
SAS_DATE = intnx('day', '01Jan2018'd, 125);
If you need further assistance, please post some sample data and the expected output so we can test it. Please post data as text.
@mnflower wrote:
I'd like to find code that takes Ethiopian dates dd/mm/yyyy and converts them into Gregorian dates, any format is fine.
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.
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
days depending on where leap year falls. Does anyone have experience with this?
@Reeza, I think it's more complicated than that. Ethiopia has a very peculiar calendar: https://en.wikipedia.org/wiki/Ethiopian_calendar
The year starts at September 11 (Gregorian) in the current era (between 1900 and 2100)
For a successful conversion, we need to accomodate that and the different count in years.
Wouldn't it still be the same math, but then subtract the number of days to Sept 11?
Thank you for the replies. This is the first time I've posted anything and I'm impressed with the
willingness to help. I've chased down several rabbit holes and your responses reinforce how
complicated a mathematical approach to this problem would be for someone like me who is not
very skilled in this area. I changed by approach. My project only needs 10 years worth of Ethiopian
dates with matching Gregorian dates. I created a table using an online date converter (one date
at a time) of where Ethiopian leap years fell and Gregorian leap years fell. Then I started with the
first Ethiopian date of our data collection period and found the matching Gregorian date. Then I
created one year's worth of corresponding dates. I use a very flexible editor so this took me about
and hour. I allowed for 12 months of 30 days and 1 month of 5 days (6 if leap year) for the Ethiopian
side and the regular Gregorian months with their unique number of days for the Gregorian side. As
I built each additional year, I watched for leap years on both sides. The whole process took me about
5 hours including checking. I created several thousand records in a text file of two variables, an Ethiopian
date and a Gregorian date. I have that data available as a SAS data file that I can sort depending on
which date I need to match. This allows me to have the Ethiopian date AND the Gregorian date
defined as a SAS date in my code. I can add the number of days I want to the Gregorian date and
then look up the Ethiopian date that matches the Gregorian date. While I know this is not a very
elegant solution, it's working for me.
Well done!
If you want, you can now create formats using your values to ease the conversion process back and forth.
This aroused my curiosity.
Here is a program that should create the correct Ethiopian date fields and the corresponding Gregorian date.
Under your control. 🙂
[Edited: Gregorian, not Julian obviously. Brain fade... Sigh... ]
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;
DAY | MONTH | YEAR | GREGORIAN |
23 | 7 | 2010 | 01Apr2018 |
24 | 7 | 2010 | 02Apr2018 |
25 | 7 | 2010 | 03Apr2018 |
26 | 7 | 2010 | 04Apr2018 |
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:
http://www.sascommunity.org/wiki/Sometimes_One_Needs_an_Option_with_Unusual_Dates
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.
Art, CEO, AnalystFinder.com
@art297 sascommunity.org will be missed.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.