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).
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.