Returns the interval of the seasonal cycle, given a date, time, or datetime interval. Returns the number of boundaries of intervals of the given kind that lie between the two date or datetime values. INTCK( ' date-interval', date1, date2 ) INTCK( ' datetime-interval', datetime1, datetime2 ) For correct results, date intervals should be used with date values, and datetime intervals should be used with datetime values. For example, the seasonal cycle for INTERVAL='DAY' is 'WEEK', so INTCINDEX(’DAY’,’01SEP78’D) returns 35 since September 1, 1978, is the sixth day of the th week of the year. Returns the index of the seasonal cycle given an interval and an appropriate SAS date, datetime, or time value. INTCINDEX( ' date-interval', date ) INTCINDEX( ' datetime-interval', datetime ) Returns the hour from a SAS datetime or time value. For example: EASTER2000 = HOLIDAY(’EASTER’, 2000) HOUR( datetime ) Valid values for holiday are 'BOXING', 'CANADA', 'CANADAOBSERVED', 'CHRISTMAS', 'COLUMBUS', 'EASTER', 'FATHERS', 'HALLOWEEN', 'LABOR', 'MLK', 'MEMORIAL', 'MOTHERS', 'NEWYEAR','THANKSGIVING', 'THANKSGIVINGCANADA', 'USINDEPENDENCE', 'USPRESIDENTS', 'VALENTINES', 'VETERANS', 'VETERANSUSG', 'VETERANSUSPS', and 'VICTORIA'. Returns a SAS date value for the holiday and year specified. Returns a SAS time value for hour, minute, and second values. Returns a SAS datetime value for date, hour, minute, and second values. Returns the day of the month from a SAS date value. Returns the current date and time of day as a SAS datetime value. Returns the date part of a SAS datetime value as a date value. For example, DATE = DATEJUL(99001) assigns the SAS date value '01JAN99'D to DATE, and DATE = DATEJUL(1999365) assigns the SAS date value '31DEC1999'D to DATE. Returns the SAS date value given the Julian date in yyddd or yyyyddd format. However, in the previous table the difference in weeks was calculated as 2 since there were two partial weeks that fit between these two dates.Returns today’s date as a SAS date value. In this table, the difference in weeks between Jan 1st and Jan 9th is calculated as 1 since only one whole week can fit between these dates. Notice the difference between this table and the previous table. Months_diff = intck(' months', start_date, end_date, ' c') Weeks_diff = intck(' weeks', start_date, end_date, ' c') Note that we can use the ‘ c‘ argument in the INTCK function to only calculate the difference in complete days, weeks, and months: /*create new dataset*/ĭays_diff = intck(' day', start_date, end_date, ' c') The three new variables show the difference between start_date and end_date in days, weeks, and months. Months_diff = intck(' months', start_date, end_date) Weeks_diff = intck(' weeks', start_date, end_date) We can use the following code to calculate the difference between the values in the start_date and end_date variables in days, weeks, and months: /*create new dataset*/ĭays_diff = intck(' day', start_date, end_date) Suppose we have the following dataset in SAS that contains two date variables: /*create dataset*/ Example : Calculate Difference Between Dates in SAS The following example shows how to use this function in practice. method: Whether to count complete intervals (‘D’ = No (Default), ‘C’ = Yes).interval: Interval to calculate (day, week, month, year, etc.).INTCK(interval, start date, end data, method) This function uses the following basic syntax: You can use the INTCK function in SAS to quickly calculate the difference between two dates in SAS.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |