Here is one way that does not require neither do loops or arrays.
data one;
input m1-m12;
cards;
0 1 4 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 5 0 6 0
;
run;
data two;
set one;
zero = sum(m1=0,m2=0,m3=0,m4=0,m5=0,m6=0,
m7=0,m8=0,m9=0,m10=0,m11=0,m12=0);
nonzero = 12 - zero;
put nonzero=;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.