You didn't provide an example of what you want the resulting file to look like, so one can only guess. Here is my guess:
data have;
input Obs ID disease aware lab;
cards;
1 2 . 0 .
2 5 1 1 .
3 7 . 0 .
4 10 . . .
5 12 2 0 1
6 13 2 0 1
7 14 . 0 .
8 15 . 1 .
9 16 3 0 1
10 24 . 0 .
11 25 . 1 .
12 29 2 0 2
13 33 . 0 .
14 34 . 1 .
15 45 . 0 .
16 46 5 1 1
17 55 . 0 .
18 56 . 0 .
19 57 4 0 2
20 59 . 0 .
;
data want;
set have;
array m_aware[5];
if lab eq 1 and not missing(aware) then
m_aware[disease]=ifn(aware eq 1,1,0);
run;
HTH,
Art, CEO, AnalystFinder.com
... View more