BookmarkSubscribeRSS Feed
PQK
Calcite | Level 5 PQK
Calcite | Level 5
I have a data table with 1 variable classified by date. I would like to use a function to change the date format so that it complies with the ISO 8601 calendar week. Example follows:

Date------SAS Format--ISO 8601
2011/1/3--18630-------2011CW0101
2011/1/4--18631-------2011CW0102
2011/1/5--18632-------2011CW0103
2011/1/6--18633-------2011CW0104
2011/1/7--18634-------2011CW0105
2011/1/8--18635-------2011CW0106
2011/1/9--18636-------2011CW0107
(the dashes inserted above are for clarity only)

The above series progresses on until the last day of 2011 calendar year on 01JAN2012, or 2011CW5207.

I searched through the forum and SAS community and couldn’t find any reference to this type of a date/time function.

Any help would be greatly appreciated.
3 REPLIES 3
Patrick
Opal | Level 21
Hi

The following link gives you the overview over SAS existing ISO8601 formats: http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a003169814.htm

If this is not enough then you have always the possibility to create your own picture format:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473467.htm

HTH
Patrick
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Start by looking at the WEEKV format.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search arguments, this topic / post:

iso 8601 calendar week date format site:sas.com

weekv format site:sas.com
PQK
Calcite | Level 5 PQK
Calcite | Level 5
Patrick & sbb,

Thank you very much for the replies!

THe WEEKV format suggestion put me in the right direction. In combination with the WEEK(date,'v') function I was able to display dates and sum quantities based on the Mon - Sun calendar week system.

Best Regards,

PDK

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2090 views
  • 0 likes
  • 3 in conversation