I'm trying to convert my MS Access databases to SAS. The first stumbling block I ran into was calculating years (or any date intervals). There are a lot of SAS functions for dates that work for the majority of users. Unfortunately, I need special intervals that do not work with these function. The beginning or ending dates for a year (any interval for that matter, month, or quarter) are based on the number of days that are in that week. For example, I will count all dates between 12/29/2013 and 1/2/2015 as occurring in 2014. Each week begins on a Sunday and ends on Saturday- common. However, For 2014, because there are only two days following 12/29/2013, we count the two days after the 29th in 2014. Thus, whenever an interval contains four or more days, it belongs to that interval. Thus using something like variable2 = Year(Date Variable) will count records on 12/30/2013 or 1/2/2015 in the wrong year. Here is what I've tried in SAS: The existing date in my database is Edate which is imported as a date. I define a variable like EYear. Then I've tried to assign Edate to EYear with and If and Else If statements like (tried with and with out quotes etc.): If Edate >= 12/29/2013 and Edate <= 01/02/2015 then EYear = 2014; <--Doesn't work and has me baffled and it's probably something simple. Coming from a VB background I would program it something like: Select Case Edate Case <= '12/31/2011' Eyear = 2011 Case <= '12/29/2012' Eyear = 2012 Case <= '12/28/2013' Eyear = 2013 Case <= '1/2/2015' Eyear = 2014 End Select Any help would be greatly appreciated. Thank you in advance.
... View more