Desktop productivity for business analysts and programmers

Is there a function that will change a date to ISO 8601 calendar week?

Reply
Contributor PQK
Contributor
Posts: 21

Is there a function that will change a date to ISO 8601 calendar week?

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.
Respected Advisor
Posts: 4,137

Re: Is there a function that will change a date to ISO 8601 calendar week?

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
Super Contributor
Super Contributor
Posts: 3,174

Re: Is there a function that will change a date to ISO 8601 calendar week?

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
Contributor PQK
Contributor
Posts: 21

Re: Is there a function that will change a date to ISO 8601 calendar week?

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
Ask a Question
Discussion stats
  • 3 replies
  • 388 views
  • 0 likes
  • 3 in conversation