![]() | ![]() | ![]() | ![]() | ![]() |
http://aa.usno.navy.mil/faq/docs/holidays.php
Note: FDO- prefixed variables are "First Day Of..." for example, FDOY is first day of year. The INTNX function advances the given date by the specified interval. The interval WEEK.2 means weekly intervals with Monday as the first day of the week.
For more information on INTNX, please refer to the SAS Language Reference, Concepts under Dates, Times and Intervals. See also TS-668: SAS Dates, Times, and Interval Functions.
Beginning in SAS 9.2, the HOLIDAY FUNCTION will be available in Base SAS. Only certain common U.S. and Canadian holidays are defined for use with this function. Please refer to the SAS Language Reference, Dictionary for more details.
Click here for SAS 9.2 documentation
Related samples include Using SAS to determine dates for Easter and Compute daylight saving time.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
/********************************************************************/
/* Please be sure to read the Details tab for important information */
/* about this sample. */
/********************************************************************/
%let year=2008;
data _null_;
fdoy=mdy(1,1,&year);
/* Martin Luther King Day */
mlk_day=intnx('week.2',fdoy,(weekday(fdoy) ne 2)+2);
/* President's Day */
fdo_feb=intnx('month',fdoy,1);
pres_day=intnx('week.2',fdo_feb,(weekday(fdo_feb) ne 2)+2);
/* For years prior to 2007, daylight time begins in the United States on */
/* the first Sunday in April and ends on the last Sunday in October. */
if &year <= 2006 then do;
fdo_apr=intnx('month',fdoy,3);
dst_beg=intnx('week.1',fdo_apr,(weekday(fdo_apr) ne 1));
fdo_oct=intnx('month',fdoy,9);
dst_end=intnx('week.1',fdo_oct,(weekday(fdo_oct) in (6,7))+4);
end;
/* Starting in March 2007, daylight time in the United States will begin */
/* on the second Sunday in March and end on the first Sunday in November. */
/* For more information, one reference is */
/* http://aa.usno.navy.mil */
else do;
fdo_mar=intnx('month',fdoy,2);
dst_beg=intnx('week.1',fdo_mar, (weekday(fdo_mar) in (2,3,4,5,6,7))+1);
fdo_nov=intnx('month',fdoy,10);
dst_end=intnx('week.1',fdo_nov,(weekday(fdo_nov) ne 1));
end;
/* Memorial Day */
fdo_may=intnx('month',fdoy,4);
mem_day=intnx('week.2',fdo_may,(weekday(fdo_may) in (1,7))+4);
/* Independence Day */
ind_day=mdy(7,4,&year);
/* Labor Day */
fdo_sep=intnx('month',fdoy,8);
lab_day=intnx('week.2',fdo_sep,(weekday(fdo_sep) ne 2));
/* Columbus Day */
fdo_oct=intnx('month',fdoy,9);
col_day=intnx('week.2',fdo_oct,(weekday(fdo_oct) ne 2)+1);
/* Election Day */
fdo_nov=intnx('month',fdoy,10);
elec_day=intnx('week.3',fdo_nov,1);
/* Veteran's Day */
vet_day=mdy(11,11,&year);
/* Thanksgiving Day */
thks_day=intnx('week.5',fdo_nov,(weekday(fdo_nov) ne 5)+3);
/* Christmas Day */
xmas_day=mdy(12,25,&year);
/* Write results to SAS log */
put mlk_day= worddate. //
pres_day= worddate. //
dst_beg= worddate. //
mem_day= worddate. //
ind_day= worddate. //
lab_day= worddate. //
col_day= worddate. //
dst_end= worddate. //
elec_day= worddate. //
vet_day= worddate. //
thks_day= worddate. //
xmas_day= worddate.
;
run;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
OUTPUT to SAS log mlk_day=January 21, 2008 pres_day=February 18, 2008 dst_beg=March 9, 2008 mem_day=May 26, 2008 ind_day=July 4, 2008 lab_day=September 1, 2008 col_day=October 13, 2008 dst_end=November 2, 2008 elec_day=November 4, 2008 vet_day=November 11, 2008 thks_day=November 27, 2008 xmas_day=December 25, 2008
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Functions ==> Date and Time Data Management ==> Manipulation and Transformation ==> Date and Time SAS Reference ==> Functions ==> Date and Time ==> INTNX |
| Date Modified: | 2008-06-04 11:42:40 |
| Date Created: | 2004-09-30 14:09:01 |
| Product Family | Product | Host | Starting Release | Ending Release |
| SAS System | Base SAS | All | 6.12 | n/a |





