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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.