In the given sample dataset, I’m adding fiscal week from a date column “TX_DT”. The fiscal year runs from Feb through Jan in a given year, for example, if we consider FY2022 (Feb’22 – Jan’23), 2022-02-01 will be fiscal week 1 and 2023-01-31 will be fiscal week 52. I’m using the code below to add fiscal week, however, the dates ranging between 2023-02-01 and 2023-02-05 are assigned 0 for their fiscal week. Dates post 2023-02-05 are assigned fiscal week 1 and so on….How can I make sure that my fiscal week starts from 2023-02-01. Also, this code starts the fiscal week from Saturday through Sunday. What changes can be made in the code if the fiscal week were to run from Monday through Sunday?
data temp_summ;
set temp;
Sales_Yearmon = year(TX_DT)*100 + month(TX_DT);
week_normal = week(TX_DT);
dat2 = intnx('month12.2',TX_DT,0);
week_F = intck('week',dat2,TX_DT);
format dat2 date9.;
run;
Please note that the date column “TX_DT” is of numeric data type of ‘YYMMDD10.’ Format and ‘YYMMDD10.’ Informat.
Look at the V descriptor option for the WEEK function.
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!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: