- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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:
- Should you include both the start points and end point in your interval, or just one of them?
- Do interval definitions require < vs. <= ?
- Could either z or x take on a missing value? Those could get assigned to the lowest interval, probably not a good result.
Regardless of the details, all of your requirements can be fulfilled using days, without calculating weeks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you only want integer results, use the FLOOR function.