The sample data you shared and the screenshot with the expected count of 59 for row 1 don't match. I've amended the sample data for row one to match your screenshot.
Based on the discussions I'm still not sure what you really want/need. Below code provides 3 calculation options. Have a look at sample data row 2 and the different results when the visit date doesn't start on the first of the month.
data have;
infile datalines truncover;
input User_ID $ (Vst_dt1 - Vst_dt10) (:date9.);
format User_ID $2. Vst_dt: date9.;
datalines;
01 01Feb2023 . . . . . 01Aug2023
99 05Feb2023 . . . . . 14Aug2023
02 . 01Mar2023 01Apr2023 01May2023 . . 01Aug2023 01Sep2023 01Oct2023 .
03 . . 01Apr2023 01May2023 . . . . . .
04 . . . 01May2023 01Jun2023 01Jul2023 . . 01Oct2023 01Nov2023
05 01Feb2023 01Mar2023 01Apr2023 . . . 01Aug2023 01Sep2023 . .
;
data want;
set have;
array mth{*} Vst_dt:;
do i=1 to dim(mth);
if not missing(mth[i]) then
do;
mth_count =sum(mth_count ,1);
day_count_1 =sum(day_count_1 ,day(intnx('month',mth[i],0,'e')));
day_count_2 =sum(day_count_2 ,intnx('month',mth[i],0,'e')-mth[i]+1);
end;
end;
drop Vst_dt:;
run;
proc print data=want;
run;
... View more