As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.
Here are some tips for How to share your SAS knowledge with your professional network.
The INTNX function manipulates dates, times or datetimes and allows SAS to calculate the beginning, end, or middle of a period or time interval or a corresponding date in another period or time interval, for a given date, time or datetime. Periods can be expressed in terms of seconds, minutes, hours, days, weeks, months, years or custom periods with part and multiple periods and variable stating points also able to be set.
The INTNX function has a broad range of applications including reporting and time series analysis. If a dataset contains dates, times or datetimes of events then the INTNX function will readily allow those events to be aggregated into reporting periods.
INTNX(period, inputdateortime, increment [, position])
- period is a character variable, or constant, that describes the period by its basic interval, periodic multiple and its start point offset.
- inputdateortime is a date, time or datetime variable, (or constant), that is used as the starting point to calculate the resulting target period.
- increment is an integer variable, or constant, that indicates how many periods to advance (positive values) or retard (negative values) to the target period.
- position is a character variable, or constant, that specifies the function return the beginning, end, middle or same day of the target period. (optional) If omitted then the beginning date, time or datetime of the target period is calculated.
A wide range of intervals are available for working with dates, including.
When working with Date-Times put DT in front of the above names e.g. DTYEAR, DTMONTH, etc.
When working with Date-Times and Times the following intervals can also be used.
- SECOND ;
For more information see:
- Paper 062-30: A Shift in Time: Using SAS® Date Alignment Operators, Andrew H. Karp, Sierra Information Services, Sonoma, CA USA
- About Date and Time Intervals, SAS(R) 9.3 Language Reference: Concepts, Second Edition
- INTNX Function examples
- Using sysfunc with intnx
- The Woes of Federal Fiscal Year and Tips:INTNX function with Federal Fiscal Year