BookmarkSubscribeRSS Feed
hwangnyc
Quartz | Level 8

Hi everyone,

 

I'm using the WEEK function and I get a column that has 0-53.

 

Is there a format that I can apply to have it read:

 

1 = 1/7/19 - 1/13/19

2 = 1/14/19 - 1/20/19

 

Thanks in advance!

 

Henry  

 

2 REPLIES 2
ballardw
Super User

The week function for a specific year can be adjusted to do this using the V modifier which starts a week on Monday.

However the function also considers the week 1 as the week that includes both January 4 and the first Thursday.

For 2019 this does what you request but is not a generic solution because you have not specified what your rule might be for other years:

data example;
   do date='01JAN2019'd to '31DEC2019'd;
      week = week(date,'V') -1;
      output;
   end;
   format date date9.;
run;

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 16. 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
  • 2 replies
  • 577 views
  • 1 like
  • 3 in conversation