Long beats wide certainly applies.
Below how you can dynamically build an expression where zero or missing becomes 0 and any other value 1 so that you just can sum the elements to get your count.
data have;
array month_ {24} 8;
month_7=10;
month_9=5;
month_24=-10;
month_2=0;
run;
%let expr_list=;
proc sql;
select catx(' ',name,'not in (0,.)') into :expr_list separated by ','
from dictionary.columns
where libname='WORK' and memname='HAVE' and upcase(name) like 'MONTH^_%' escape '^'
;
quit;
%put %nrbquote(&expr_list);
data want;
length cnt_not0orMiss 8;
set have;
cnt_not0orMiss=sum(&expr_list);
run;