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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.