Use an array and loop over the array count how many members equal minus one.
data want;
set have;
array x var1-var4 ;
want=0;
do i=1 to dim(x);
want + (x(i)=-1);
end;
run;
But if you changed your coding and replaced -1 with missing value (or one of the 27 special missing values) then you could use NMISS() function. Plus you could use other functions like MIN(),MAX(), MEAN() on the set of variables since they would ignore the missing values.
data have;
input var1-var4 ;
cards;
. 20 4 .
60 . . .
;
data want;
set have ;
want = nmiss(of var1-var4);
run;
... View more