BookmarkSubscribeRSS Feed
Meteorite | Level 14

It does not:

1    data _null_;
2    do date = '1jan2024'd to '7jan2024'd;
3      week_u=week(date, 'u');
4      week_v=week(date, 'v');
5      week_w=week(date, 'w');
6      format date yymmdd10.;
7      put (_ALL_) (=);
8    end;
9    run;

date=2024-01-01 week_u=0 week_v=1 week_w=1
date=2024-01-02 week_u=0 week_v=1 week_w=1
date=2024-01-03 week_u=0 week_v=1 week_w=1
date=2024-01-04 week_u=0 week_v=1 week_w=1
date=2024-01-05 week_u=0 week_v=1 week_w=1
date=2024-01-06 week_u=0 week_v=1 week_w=1
date=2024-01-07 week_u=1 week_v=1 week_w=1
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

Did you read documentation for week()



Polish SAS Users Group: and

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation

Diamond | Level 26

The documentation explains it clearly


The WEEK function with the U descriptor reads a SAS date value and returns the number of the week within the year. 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. Week 0 means that the first day of the week occurs in the preceding year. The fifth week of the year is represented as 05.

Paige Miller
Calcite | Level 5

Google searches haven't  included those descriptors and I have missed them.

Thanks for pointing out the correct solutions!

Super User

Start here :


And search within the SAS documentation.


Depending on your install the online help could be quite extensive and no reason to "google".



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1 like
  • 4 in conversation