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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.