BookmarkSubscribeRSS Feed
4 REPLIES 4
yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"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



PaigeMiller
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
Antero
Calcite | Level 5

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

Thanks for pointing out the correct solutions!

ballardw
Super User

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".

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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