If you end up having to use arrays a lot, then this may be a telltail of the data structured less than excellently. Here is one way that does not involve any arrays at all.
/* test data */
data one;
id=1; result="N:f;1; 3; 52; a; b"; output;
id=2; result="Y"; output;
id=3; result="N:33"; output;
id=4; result="N:1"; output;
id=5; result="N:a;b;c"; output;
run;
/* the 81 tests */
data tests;
do n = 1 to 81;
if n <= 71 then test = put(n, 2.-l);
else test = substr("abcdefghij", n-71, 1);
output;
end;
keep test;
run;
/* make a long-shaped data */
data long;
set one;
result = compress(lowcase(result),"0123456789abcdefghij;","k");
passedAll = ifn(missing(result), 1, 0);
do point = 1 to 81;
set tests point=point;
failedThis = (indexw(trimn(result), trimn(test), ";")>0);
passed = (passedAll or not failedThis);
output;
end;
keep id test passed;
run;
/* usage example: count how many people passed each test */
proc freq data=long;
table test/list missing;
where passed;
run;
/* reshape to wide -- it takes just one proc */
proc transpose data=long out=wide(drop=_:) prefix=passed;
by id;
var passed;
run;
/* check */
proc print data=wide;
var passed1-passed5;
run;
/* on lst
Obs passed1 passed2 passed3 passed4 passed5
1 0 1 0 1 1
2 1 1 1 1 1
3 1 1 1 1 1
4 0 1 1 1 1
5 1 1 1 1 1
*/
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.