Hello,
I am attempting to determine the months between many observations between two columns: assign_date and completed_date in SAS EG
From other forums I read it looked like the used the intck function, however, it does not work for me.
I noticed in most of the examples they used the intck function for two specific dates, not dates in columns. Perhaps that's why I am having errors?
proc print data=work.'test'n;
var assign_date due_date;
intck('month', assign_date, completed_date);
run;
You've got the right function, but ...
PROC PRINT will only print variables that already exist in a data set. It will not print a function derived from other variables. You will have to create a new variable in DATA step creating a new data set. Then print variables from that data set.
data new;
set test;
nmonths=intck('month',assign_date,completed_date);
run;
proc print data=new;
var assign_date completed_date nmonths;
run;
You need to assign the value to a variable.
MTHS = intck('month', ASSIGN_DATE, COMPLETED_DATE);
Since you can't use the intck function in the proc step, I think you should first calculate the value in the data step and then output it in the proc print.
You've got the right function, but ...
PROC PRINT will only print variables that already exist in a data set. It will not print a function derived from other variables. You will have to create a new variable in DATA step creating a new data set. Then print variables from that data set.
data new;
set test;
nmonths=intck('month',assign_date,completed_date);
run;
proc print data=new;
var assign_date completed_date nmonths;
run;
Whenever you use INTCK, you have to decide what it is you want to count. If the dates represent 01/31/2021 and 02/02/2021, do you want to count that as 1 month? If so, INTCK is correct (once you follow the suggestions that have been made).
@Astounding wrote:
Whenever you use INTCK, you have to decide what it is you want to count. If the dates represent 01/31/2021 and 02/02/2021, do you want to count that as 1 month? If so, INTCK is correct (once you follow the suggestions that have been made).
Setting the fourth parameter of intck to "C" (=continuous) should return 0 in such cases.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.