I don't see anything in the code that you show that resembles "Rest of the data I have classified as others. "
Are you sure that is applied to data set Custidsort? If so, you should show how.
Maybe
Proc SQL;
create table Monthlytraces as
select Month, count (Month) as No_of_monthly_traces
from (select * from custidsort where Year(datepart(tpt_date))=2022 )
group by Month;
quit;
Note that from the "data" you show we really don't know if that "month" variable is a date or string or what.