WEEKWw. Format

Writes a week number in decimal format by using the W algorithm.

Category: Date and Time
Alignment: Left

Syntax

WEEKWw.

Syntax Description

w

specifies the width of the output field.

Default 11
Range 3–200

Details

The WEEKWw. format writes the various formats depending on the specified width. Algorithm W calculates the SAS date value by using 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, with a leading zero and maximum value of 53. For example, the fifth week of the year would be represented as 05.
Here are widths, formats, and examples:
Width
Format
Example
3–4
Www
w01
5–6
yyWww
12W01
7–8
yyWwwdd
12W0101
9–10
yyyyWwwdd
2012W0101
11–200
yyyy-Www-dd
2012-W01-01

Comparisons

The WEEKVw. format writes the week number as a decimal number in the range 01–53. Weeks that begin on a Monday and week 1 of the year include January 4 and the first Thursday of the year. If the first Monday of January is 2, 3, or 4, the preceding days are part of the last week of the preceding year. The WEEKWw. format writes the week number of the year as a decimal number in the range 00–53, with Monday as the first day of week 1. The WEEKUw. format writes the week number of the year (with Sunday as the first day of the week) as a decimal number in the range 0–53, with a leading zero.

Example

sasdate = '31JAN2012'd; 
Statement
Result
----+----1----+
v=put(sasdate,weekw3.);
w=put(sasdate,weekw5.);
x=put(sasdate,weekw7.);
y=put(sasdate,weekw9.);
z=put(sasdate,weekw11.);
put v;
put w;
put x;
put y;
put z;





W05
12W05
12W0502
2012W0502
2012-W05-02

See Also

Functions:
WEEK Function in SAS Functions and CALL Routines: Reference