Updated March 15, 2023
Introduction to SAS INTNX
The SAS INTNX is one of the functions that can be used to perform the SAS date and time function that will return the SAS date value by adding the specified number of data increments to start the initial date with the next level of datas that’s the way it denotes the Interval Next which calls it as the INTCK and stands for Interval Check to compute the data algorithms.
What is SAS INTNX?
SAS INTNX() is the function that needs parameters like Interval, start_date, and a number of intervals to be added for a specified date value. The INTCK and INTNX are the types of functions that are returned with a number of time intervals and units between the dates. INTNX function is returning the SAS date as per units and specific dates to compute the operations in future scenarios.
It supports many options for to modified the default behaviors and using the CONTINUOUS option with a positive number of intervals to be the integer values. In addition to the three types of arguments that are mandatory, the fourth one is optional, and the interval unit is a measurement of the start from the date, and incremented the number for the date intervals would be accepted for positive, negative, and zero with previous dates.
SAS INTNX Function
The SAS has a number of default functions that helps to perform the SAS operations additionally with the increment and added with an additional feature. Among that intnx() is the SAS function and used for to increment the SAS date with a specified number of intervals on the three set of parameters, the fourth one is the optional one for using the SAS documentation. Multiplying and shifting the values for the data step function to return the SAS date value and information is mainly provided for the datetime and sub-arguments values to be omitted.
Below code is the basic syntax for performing the date interval in the SAS.
Syntax:
INTNX(interval, startdate-from, incremental,[alignment])
Interval is one of the parameters for measuring the unit and time intervals like days, weeks, months, and interval quarters years. The startdate -from is the SAS date value which would be incremented with a number of intervals for increment option can be zero, positive and negative option. Then we divide the article datas into the different sections which focused on the INTNX function for other functions like a date with intervals of the day, month, week, year, and time gap to be aligned with increment operations.
Steps to Create SAS INTNX()
Given below are the steps to create SAS INTNX():
1. Navigate to the below URL after login.
3. Create the basic dataset like below.
4. data work.ds;
5. format vars date9.;
6. input vars date9.;
7. datalines;
8. 10JUN2022
9. 11MAY2022
10. 13DEC2022
11. ;
12. run;
13. Then, we need to perform the intnx() function to filter the datas with intervals like date, month are other parameters.
14. ‘data work.second;
15. set work.ds;
16.
17. vars1 = intnx(‘day’, vars, 1);
18.
19. format _all_ date9.;
20. run;
We can utilize the intnx interval parameters in the SAS datasets for performing the data measurement. Available intervals are the day, week, month, and year enclosed in the quotes SAS date and the number of integers. Multipliers and shift indexes can be used with the basic interval for constructing the names and specifications.
SAS INTNX Syntax
The SAS intnx function, which is used to increment the date with a number of intervals, is an interval name that can appear in uppercase and lowercase characters. It has a possible set of values in the interval that splits the category, Interval, Starting point, and Shift period, which include the day, month, year, etc. Days interval will be started like three days, starting on Sunday and weekly with Saturday as the first day of the week. It’s supported for a six-day week with Sunday as the weekend day, but five-day the beginning of the date for the interval is returned with a default value, and nothing is to be entered after the value is triggered on the intnx function.
The end of the date, by using the interval, is mainly returned with the last day of the week, which includes the month and year. Then middle of the date interval is the middle day of the week and also includes the month and year if the date of the same day also within the interval is mainly returned using the same day, month, and year of the current activities. If the last statement is satisfied, which included the arguments for the control over the due date and already it’s derived, then we need to provide a number of suggestions on how it is to be applied for the useful dates related to the starting date, including the TODAY() function for to provide the current day which is starting day of the parameter.
Example of SAS INTNX
Given below is the example mentioned:
Code:
options vars1=(months=example1);
data example1;
format begin end date9.;
begin='01jan2022'd; end='01jan2022'd; output;
begin='02jan2022'd; end='02jan2022'd; output;
begin='03jan2022'd; end='03jan2022'd; output;
begin='04jan2022'd; end='04jan2022'd; output;
begin='05jan2022'd; end='05jan2022'd; output;
begin='06jan2022'd; end='06jan2022'd; output;
begin='07jan2022'd; end='07jan2022'd; output;
begin='08jan2022'd; end='08jan2022'd; output;
begin='09jan2022'd; end='09jan2022'd; output;
begin='10jan2022'd; end='10jan2022'd; output;
run;
data example2;
format a date9. b date9.;
a='01jan2022'd;
do inp=0 to 9;
b=intnx('months', a, inp);
put b;
end;
run;
Output:
1. In the above example, we calculated the day, month, and year of the current scenario, and we used the format like begin and end date with date9.
2. Based on the above format, we can declare the inputs in the begin and end variables.
3. The above screenshot shows each variable’s input datasets using the date format.
4. Input datas will be in date/month/year format for all the sequences.
5. Then, we can iterate the values with a number of iterations using the do a loop.
6. Using the intnx() function with parameters like months, variable1, and loop variable, perform the operation and store it on a separate variable.
7. Finally, the output will be shown on the screen.
Conclusion
SAS has many default functions, keywords, and variables to perform the data analysis more sophisticatedly based on the user requirements and dependencies. Like that intx() function is mainly performed on the date operations, which helps to increment the date, time, datetime, month, and year intervals.
Recommended Articles
This is a guide to SAS INTNX. Here we discuss the introduction, SAS INTNX function, steps, syntax, and example. You may also have a look at the following articles to learn more –