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;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.