The most useful reply from Linus demonstrated the power of using SAS PROC FORMAT to tailor "formatted" date variables as needed for display purposes.
So, combining PROC FORMAT with a DATA step to assign a SAS character variable with the desired "yyyy WEEK ww" string, derived from a SAS DATE variable, use the code below.
PROC FORMAT ;
PICTURE yyyyww
LOW-HIGH='%0Y WEEK %0U' (DATATYPE=DATE);
RUN ;
data _null_;
retain year 2008 week 2;
* convert year and week to a SAS DATE var. ;
dt = intnx('week',mdy(1,1,year),week);
* now convert back to desired display format, as ;
* as SAS character variable. ;
dtx = put(dt,yyyyww.);
putlog dt= date9. dtx= ;
run;
Another possibility that does not involve a special user SAS format is to explore using one of the SAS formats WEEKU/WEEKV/WEEKW (check your ISO requirement for when WEEK=1 starts) which can generate a format "yyyyWwwdd" but with some truncation, shown below:
data _null_;
retain year 2008 week 2;
dt = intnx('week',mdy(1,1,year),week);
length dtx $12;
dtx = put(dt,weeku9.);
dtx = tranwrd(substr(dtx,1,7),'W',' WEEK ');
putlog dt= date9. dtx= ;
run;
Hope that helps.
Scott Barry
SBBWorks, Inc.