Based on your question I'm not sure what you are asking for. Is this what you want?
data have;
format date1 date2 mmddyy10.;
date1 = '02DEC2014'd;
date2 = '03JAN2015'd;
run;
data want;
set have;
date_diff = intck('day',date1,date2);
run;
As they are date variables, you don't actually need to use a function:
data want;
set have;
date_diff = date2 - date1;
run;
Sorry the link didn't show up:
https://communities.sas.com/thread/51733
I am trying to find another code that does similar to this. The issue with this it does not work for cross year boundaries i.e December 2014 and January 2015
Post some test data. I personally would expand your data for each date then sum it up, note to transpose you would need to know year and month e.g.
data have;
effective_date="01JAN2014"d;
end_date="14FEB2015"d;
output;
run;
data inter;
set have;
do day_date=effective_date to end_date;
mnth=month(day_date);
yr=year(day_date);
output;
end;
run;
proc sql;
create table WANT as
select MNTH,
YR,
COUNT(1) as CNT
from INTER
group by YR,
MNTH;
quit;
Here are some sample data:
Visit Number Checkin Date CheckoutDate
2342 | 12/25/2014 | 1/6/2015 |
1234 | 12/27/2014 | 1/1/2015 |
Should be this:
Visit Number Checkin Date CheckoutDate Dec 2014 Jan 2015
2342 | 12/25/2014 | 1/6/2015 | 7 | 6 |
1234 | 12/27/2014 | 1/1/2015 | 5 | 1 |
Yes, my program should work on that. I wouldn't go with having dates as columns though. Its a bad idea in the longer term, I mean if you had a time period (not necessarily on one row, but over all data) of several years, you can end up with lots of columns with few data in. Better to keep it normalised as my output will do, or genericise the columns, e.g. COL1-COLx, so you can use arrays and fill up only the ones you need.
Hey RW9, I just tried and yes I can use it!
Thank you
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: