I'm totally confused!
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()?
Bart
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.
Google searches haven't included those descriptors and I have missed them.
Thanks for pointing out the correct solutions!
Start here : https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=pgmsashome&docsetTarget=h...
And search within the SAS documentation.
Depending on your install the online help could be quite extensive and no reason to "google".
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: