I like @Patrick's second solution.
data my_new_table; set my_old_table;
format date date9.;
if market = "xxxx" then do date = '01jan2022'd to '31dec2022'd;
qtr=qtr(date);
output;
end;
run;
You say you want to calculate the number of days in each quarter but don't show how it's used.
If after all this you still do not have a solution that works, I would suggest taking a step back as this is definitely an xy problem.
Rather than posting your non working code, please show us a small sample of your input data and what you want as output instead.
... View more