Hello, I am trying to create a series of count variables for two years (24 variables January19-December19 and January20-December20) that reflect the number of days in each month from a given date range. For example, consider: data WORK.DRUG(label='Drug Episode');
infile datalines;
input enrolid:$8. startdate:mmddyy10. enddate:mmddyy10.;
datalines;
12344 02/02/2019 03/04/2019
32456 03/18/2019 04/17/2019
21424 04/26/2019 05/26/2019
37625 05/25/2019 06/25/2019
34635 12/28/2019 01/28/2020
;;;; For enrolid=12344, the result I want is: January19=0, February19=26, March19=4, April19=0...etc. I have two years of data, so dates may occasionally cross years (eg last line of sample code) I have tried to follow the advice from a previous post (https://communities.sas.com/t5/SAS-Programming/Get-Number-of-days-in-each-month-between-two-dates/td-p/548014) by converting my dates to SAS date constants and running a couple of the suggested options, but get the error message my variables are uninitialized, so I think perhaps this code is for specific one-time inputs rather than a list of variables. Appreciate any insight. I'm using 9.4
... View more