Thinking outside the box, you can coerce an input statement to read a concatenation of the flag variables transformed to appear like an csv input line. Lots of tricks mashed into this answer:
DATA Step with SET and INFILE
Dummy DATALINES for INPUT to introduce _INFILE_
INFILE CARDS with TRUNCOVER to prevent LOST CARD
Held input with @@ to prevent dataline advancement
INPUT @1 to reposition parse start point
INPUT with (one:) variable list specifier to read into an array
INPUT with (binary32.:) informat list to read 1's as binary data upto next delimiter (,) using : list input modifier
MAX of one: to determine largest run of 1's
LOG2 of 1+MAX to get number of 1's in largest value that must be 2^p - 1
* faux data with 32 neg flag variables; data have;
do patid = 1 to 20;
array neg neg1-neg32;
do over neg;
neg = ranuni(123) < 0.35;
end;
output;
end;
run;
data want;
attrib longest_run length=8;
set have;
infile cards dlm=',' truncover;
if _n_ = 1 then input @1 @@; * activate _infile_;
_infile_ = translate(cats(of neg:),',','0'); * repurpose _infile_ value;
* put _infile_;
array one one1-one32;
input @1 (one:) (binary32.:) @@; * read the _infile_ (input buffer);
_error_ = 0;
longest_run = log2 (1+max(of one:));
drop one:;
cards;
.
run;
... View more