BookmarkSubscribeRSS Feed
hk24
Obsidian | Level 7

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.

1 REPLY 1
ballardw
Super User

Look at the V descriptor option for the WEEK function.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 420 views
  • 0 likes
  • 2 in conversation