@bhca60 Looking at the code you shared I believe you are overcomplicating things. I'm even not sure that you need a macro variable at all.
Why don't you explain us what you've got and what you're trying to achieve. Ideally share some sample data with us and show us the desired outcome.
Below some sample code that demonstrates how you could figure out if the days of a week (starting on Sundays) span over two months.
data demo;
length week_num 8;
format week_begin_dt dt week_end_dt weekdatx.;
do dt='01jan2024'd to '31dec2024'd;
week_num=week(dt);
week_begin_dt =intnx('week',dt,0,'b');
week_end_dt =intnx('week',dt,0,'e');
week_two_month_flg =intck('month',intnx('week',dt,0,'b'),intnx('week',dt,0,'e'));
weekday_in_diff_month_flg =intck('month',intnx('week',dt,0,'b'),dt);
output;
end;
run;
proc print data=demo;
where week_two_month_flg = 1;
run;
If you don't want to use the defaults then you also need to tell us when for you a new year and a new week starts.
... View more