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

Hi All,

I would like to add a new column that count weeks like below...

I know how to count number of rows, but here, it's different, I want to say for example week51 and year 2009 is Week1 like below. Your help will be much appreciated. Many Thanks

  CUST_10000048_V2; 

SET CUST_10000048;

RETAIN COUNTER;

BY SOLD_TO_ORG_ID DELIVERY_YEAR DELIVERY_WEEK;

IF FIRST.SOLD_TO_ORG_ID AND FIRST.DELIVERY_YEAR AND FIRST.DELIVERY_WEEK THEN COUNTER=0;

COUNTER=COUNTER+1;

  ;

SOLD_TO_ORG_IDDELIVERY_DATEWEEK_YEARDELIVERY_YEARDELIVERY_WEEKNEW_COLUMN
1000004821/12/200951 - 20092009511
1000004823/12/200951 - 20092009511
1000004828/12/200952 - 20092009522
1000004830/12/200952 - 20092009522
1000004804/01/20101 - 2010201013
1000004808/01/20101 - 2010201013
1000004811/01/20102 - 2010201024
1 ACCEPTED SOLUTION

Accepted Solutions
Question
Fluorite | Level 6

Sorry, Many thanks for your reply...

View solution in original post

3 REPLIES 3
Reeza
Super User

Please don't post to multiple area's.

DATA  CUST_10000048_V2; 

SET CUST_10000048;

RETAIN COUNTER 0;

BY SOLD_TO_ORG_ID DELIVERY_YEAR DELIVERY_WEEK;

IF FIRST.DELIVERY_WEEK THEN COUNTER=counter+1;

run;

Question
Fluorite | Level 6

Sorry, Many thanks for your reply...

Question
Fluorite | Level 6

Thank you again, it works perfectly Smiley Happy

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1740 views
  • 0 likes
  • 2 in conversation