Hi Guys
suppose a person visit respective dates I want to count no of days between two dates
required answer is 2 days as per below dates
data count;
st_date ='01JAN2021'd;
end_date='02JAN2021'd;
fromat st_date end_date date9.;
count_total=intck('day',st_date,end_date);
put count_total= ;
run;
If you need to include both the start and end day, add 1 to the result.
INTCK counts the number of interval boundaries between the values.
suppose three days then
data count;
1st_date ='01JAN2021'd;
2nd__date='02JAN2021'd;
3rd_date='05APR2021'd;
fromat 1st_date 2nd_date 3rd_date date9.;
count_total=intck('day',st_date,end_date)+1;
put count_total= ;
run;
Apart from the obvious syntax error in the FORMAT statement, this code will only create missing values.
I STRONGLY suggest you run your code in your SAS environment and see what it does (Maxim 4).
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.