It seems like a matter of adding your city variable to the sort and by statements. I mocked up some data and used it to build the SAS code below. The output would be a unique city-month listing with day count. Sorting by city and month, and then using first.month will ID the first instance of month for that sort pair and reset the counter to 0. All of this is assuming your data is set up such that it's a unique city, month, and day record.
/*Make dummy data for testing*/
data ozone (keep=city month);
do city=1 to 3;
do month=1 to 3;
do day=1 to 31;
output;
end;
end;
end;
run;
/*Sort on the variables by which you want to aggregate*/
proc sort data=ozone;
by city month;
run;
/*Make a counter - will reset at the start of every city month combo*/
data counter;
set ozone;
by city month;
if first.month then day_count=0;
day_count + 1;
/*Can use if you want to output a single city-month record with day count*/
if last.month then output;
run;
proc print data=counter; run;
Output looks like the attached screen grab.
