Hi,
I have a quick question on SAS dates, just wondering which one to use.
data check;
y='22jun2015'd;
z='16sep2015'd;
weeks=(z-y)/7;
weeksfn=intck('week',y,z);
run;
So Assuming we have this type of question According to the SAP the following should be used to categorize time in weeks
so for weeks we have 12.285714286
while weeksfn we have 12.
SAP says
The time intervals will be defined as:
So will this be categorized under 0-12 as per the intck function
or it will be categorized as >12-26 weeks as per long division?
@himself wrote:
Hi,
I have a quick question on SAS dates, just wondering which one to use.
data check; y='22jun2015'd; z='16sep2015'd; weeks=(z-y)/7; weeksfn=intck('week',y,z); run;
So Assuming we have this type of question According to the SAP the following should be used to categorize time in weeks
so for weeks we have 12.285714286
while weeksfn we have 12.
SAP says
The time intervals will be defined as:
- ‘0 – 12 weeks’
- ’>12 – 26 weeks’
- ‘> 26 weeks’
So will this be categorized under 0-12 as per the intck function
or it will be categorized as >12-26 weeks as per long division?
This is completely up to you. In your program, you can handle either way, based upon your needs.
Why are you complicating matters? Don't even compute weeks. Just use the number of days. For example:
length interval $ 15;
if z-y < 84 then interval = '0 - 12 weeks';
Details to watch for:
Regardless of the details, all of your requirements can be fulfilled using days, without calculating weeks.
Just base your categories on number of days. You can label them using the text from the SAP, but use the actual number of days in the calculations.
You should also learn about the extra option to INTCK() that lets you control how it counts intervals. The default is count the number of inter boundaries crossed. So how many Sundays are in between the two dates. But if you use CONT for the final option it will use the actual day of the week at the start of the interval when determining the number of intervals. So that should be more like your division by 7.
data check;
input (y z) (:date.);
format y z date9.;
days = z-y;
weeks1 = days/7;
weeks2 = intck('week',y,z);
weeks3 = intck('week',y,z,'cont');
cards;
22jun2015 16sep2015
01jan2021 01mar2021
;
Obs y z days weeks1 weeks2 weeks3 1 22JUN2015 16SEP2015 86 12.2857 12 12 2 01JAN2021 01MAR2021 59 8.4286 9 8
If you only want integer results, use the FLOOR 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 25. 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.