Any ideas on how to do this easily? I am guessing there is a way to do this in one step instead of 2.
To get a running count of weeks and months, do
weeknum = intck('week','01jan2001'd,date);
monthnum = intck('month','01jan2001'd,date);
1) Should the week number of 01Jan2001 be the same as 01jan2002? Or should they be 1 and 53 eg?
2) What values should date_1 and date:2 take?
1. The week number of 01JAN2001 and 01JAN2002 should be different. 01JAN2002 should have a week number of 53, and so on. Here's what my data looks like.
2. I already have values for date_1 and date_2, and what I want to do is match the date_1 and date_2 values to the week number for the week that it falls in. For example a date_1 value of 1JAN2001 would have a week value of 1 and a date_2 value of 31DEC2001 would have a week value of 52.
Basic approach is to start with a SAS date value.
Then it looks like functions WEEKU, WEEKV or WEEKW, which determine "week" by which day starts as week and how to treat things at the beginning of the year, and the MONTH function.
But you really need to show some values especially to explain date_01 and date_02. Your description makes them sound like two variables with the same value.
@JJ_83 wrote:
- The problem I see with the week and month functions is that it returns the week number for the year, but since I have multiple years I need a unique number for each week.
- Here is what my data looks like now.
Still haven't shown what you expect for the output.
You might be looking for INTCK function which returns the count of intervals between two dates:
Weeknumber = intck('week', '01JAN2001'd, somedatevariable);
And as I said before your requirement 2 does not make much sense as stated and you really need to supply examples of the output.
You really are not providing many details.
To get a running count of weeks and months, do
weeknum = intck('week','01jan2001'd,date);
monthnum = intck('month','01jan2001'd,date);
Thank you! That's exactly what I needed!
That could be a problem because of February and it's 28-29 days a month. It was fixed with an additional C++ class in employee monitoring software.
The INTCK function takes care of this.
@ZigmudLeic wrote:
That could be a problem because of February and it's 28-29 days a month. It was fixed with an additional C++ class in employee monitoring software.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.