Writes a week number in decimal format by using the U algorithm.
Category: 
Date and Time

Alignment: 
left


w

specifies the width of the output field.
The WEEKUw.
format writes a weeknumber format. The WEEKUw.
format writes the various formats depending on the specified width. Algorithm
U calculates the SAS date value by using the number of the week within the
year (Sunday is considered the first day of the week). The numberoftheweek
value is represented as a decimal number in the range 053, with a leading
zero and maximum value of 53. For example, the fifth week of the year would
be represented as 05.
Refer to the following table for widths, formats, and examples:
Widths 
Formats 
Examples 
34 
Www 
w01 
56 
yyWww 
03W01 
78 
yyWwwdd 
03W0101 
910 
yyyyWwwdd 
2003W0101 
11200 
yyyyWwwdd 
2003W0101 
The WEEKVw.
format writes the week number as a decimal number in the range 0153,
with weeks beginning on a Monday and week 1 of the year including 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. The WEEKWw. format writes the
week number of the year as a decimal number in the range 0053, with
Monday as the first day of week 1. The WEEKUw.
format writes the week number of the year (Sunday as the first day of the
week) as a decimal number in the range 053, with a leading zero.
sasdate = '01JAN2003'd;
Statements 
Results 

+1+

v=put(sasdate,weeku3.);
w=put(sasdate,weeku5.);
x=put(sasdate,weeku7.);
y=put(sasdate,weeku9.);
z=put(sasdate,weeku11.);
put v;
put w;
put x;
put y;
put z;

W00
03W00
03W0004
2003W0004
2003W0004

Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.