BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lai302120
Calcite | Level 5

Hi,

I would like to increment the week number by 1 every 7 days, starting from Apr 4 to "some end date".

My dataset looks like this:

Datepcode
4-Apr-14V5C0B3
4-Apr-14V5C0B4
5-Apr-14V5C0B3
5-Apr-14V5C0B4
6-Apr-14V5C0B3
6-Apr-14V5C0B4
7-Apr-14V5C0B3
7-Apr-14V5C0B4
8-Apr-14V5C0B3
8-Apr-14V5C0B4
9-Apr-14V5C0B3
9-Apr-14V5C0B4
10-Apr-14V5C0B3
10-Apr-14V5C0B4
11-Apr-14V5C0B3
11-Apr-14V5C0B4
12-Apr-14V5C0B3
12-Apr-14V5C0B4
13-Apr-14V5C0B3
13-Apr-14V5C0B4
14-Apr-14V5C0B3
14-Apr-14V5C0B4
15-Apr-14V5C0B3
15-Apr-14V5C0B4
16-Apr-14V5C0B3
16-Apr-14V5C0B4
17-Apr-14V5C0B3
17-Apr-14V5C0B4
18-Apr-14V5C0B3
18-Apr-14V5C0B4
19-Apr-14V5C0B3
19-Apr-14V5C0B4

 

and I want it to look like this:

DatepcodeWEEK
4-Apr-14V5C0B31
4-Apr-14V5C0B41
5-Apr-14V5C0B31
5-Apr-14V5C0B41
6-Apr-14V5C0B31
6-Apr-14V5C0B41
7-Apr-14V5C0B31
7-Apr-14V5C0B41
8-Apr-14V5C0B31
8-Apr-14V5C0B41
9-Apr-14V5C0B31
9-Apr-14V5C0B41
10-Apr-14V5C0B31
10-Apr-14V5C0B41
11-Apr-14V5C0B32
11-Apr-14V5C0B42
12-Apr-14V5C0B32
12-Apr-14V5C0B42
13-Apr-14V5C0B32
13-Apr-14V5C0B42
14-Apr-14V5C0B32
14-Apr-14V5C0B42
15-Apr-14V5C0B32
15-Apr-14V5C0B42
16-Apr-14V5C0B32
16-Apr-14V5C0B42
17-Apr-14V5C0B32
17-Apr-14V5C0B42
18-Apr-14V5C0B33
18-Apr-14V5C0B43
19-Apr-14V5C0B33
19-Apr-14V5C0B43

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

I have to assume you made a slight error in your post and that April 18 would increment to week=3.  Here's a statement you could add to your DATA step:

 

week = 1 + int( (date - '04apr2014'd) / 7);

 

Good luck.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

I have to assume you made a slight error in your post and that April 18 would increment to week=3.  Here's a statement you could add to your DATA step:

 

week = 1 + int( (date - '04apr2014'd) / 7);

 

Good luck.

lai302120
Calcite | Level 5

thanks!!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1885 views
  • 0 likes
  • 2 in conversation