Hello Community, I'm fairly new to SAS and need your help with a query. I have a date column in my dataset, which is of 'DATE' type variable and I would like to add a column to the dataset that gives me the week number corresponding to the dates. I can use the week() function but there's slightly a different requirement in my case as I want the week number to start from 1 irrespective of the month that the date starts from. Please note that my date always starts with Monday and may have multiple occurrences of same date. Also, I want the week to start from Monday and end on Sunday, so the week number should be corresponding to it. Below is a sample dataset. date_var week_no 2023-06-12 1 2023-06-12 1 2023-06-13 1 2023-06-14 1 2023-06-15 1 2023-06-16 1 2023-06-17 1 2023-06-18 1 2023-06-19 2 2023-06-20 2 2023-06-21 2 2023-06-22 2 2023-06-23 2 2023-06-24 2 2023-06-25 2 2023-06-26 3 2023-06-27 3 2023-06-28 3 2023-06-29 3 2023-06-30 3 2023-07-01 3 2023-07-02 3 I have tried the query below but it doesn't start the week from 1. data final_table; set temp_table; week_no=week(date_var); run;
... View more