Returns the week-number value.
Category: | Date and Time |
specifies the SAS data value. If the sas-date argument is not specified, the WEEK function returns the week-number value of the current date.
specifies the value of the descriptor. The following descriptors can be specified in uppercase or lowercase characters.
specifies the number-of-the-week
within the year. Sunday is considered the first day of the week. The
number-of-the-week value is represented as a decimal number in the
range 0–53. Week 53 has no special meaning. The value of week('31dec2006'd, 'u')
is 53.
Tip | The U and W descriptors are similar, except that the U descriptor considers Sunday as the first day of the week, and the W descriptor considers Monday as the first day of the week. |
See | The U Descriptor |
specifies the number-of-the-week whose value is represented as a decimal number in the range 1–53. Monday is considered the first day of the week and week 1 of the year is the week that includes both January 4th and the first Thursday of the year. If the first Monday of January is the 2nd, 3rd, or 4th, the preceding days are part of the last week of the preceding year.
See | The V Descriptor |
specifies the number-of-the-week
within the year. Monday is considered the first day of the week. The
number-of-the-week value is represented as a decimal number in the
range 0–53. Week 53 has no special meaning. The value of week('31dec2006'd, 'w')
is 52.
Tip | The U and W descriptors are similar except that the U descriptor considers Sunday as the first day of the week, and the W descriptor considers Monday as the first day of the week. |
See | The W Descriptor |
week('01jan2006'd, 'v')
and week('30dec2005'd,
'v')
both return a value
of 52. This means that both dates occur in week 52 of the year 2005.
U | specifies that the last week (52 or 53) in the year can contain less than 7 days. A Sunday to Saturday period that spans 2 consecutive Gregorian years is designated as 52 and 0 or 53 and 0. |
V | specifies that the last week (52 or 53) of the ISO year contains 7 days. However, the last week of the ISO year can span the current Gregorian and next Gregorian year. |
W | specifies that the last week (52 or 53) in the year can contain less than 7 days. A Monday to Sunday period that spans two consecutive Gregorian years is designated as 52 and 0 or 53 and 0. |
title 'Values of the U, V, and W Descriptors'; data a(drop=i date0 date1 y); date0 = '20dec2005'd; do y = 0 to 5; date1 = intnx("YEAR",date0,y,'s'); do i = 0 to 20; date = intnx("DAY",date1,i); year = YEAR(date); week = week(date); week_u = week(date, 'u'); week_v = week(date, 'v'); week_w = week(date, 'w'); output; end; end; format date WEEKDATX17.; run; proc print; run;