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_ID | DELIVERY_DATE | WEEK_YEAR | DELIVERY_YEAR | DELIVERY_WEEK | NEW_COLUMN |
10000048 | 21/12/2009 | 51 - 2009 | 2009 | 51 | 1 |
10000048 | 23/12/2009 | 51 - 2009 | 2009 | 51 | 1 |
10000048 | 28/12/2009 | 52 - 2009 | 2009 | 52 | 2 |
10000048 | 30/12/2009 | 52 - 2009 | 2009 | 52 | 2 |
10000048 | 04/01/2010 | 1 - 2010 | 2010 | 1 | 3 |
10000048 | 08/01/2010 | 1 - 2010 | 2010 | 1 | 3 |
10000048 | 11/01/2010 | 2 - 2010 | 2010 | 2 | 4 |
Sorry, Many thanks for your reply...
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;
Sorry, Many thanks for your reply...
Thank you again, it works perfectly
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.