Hi, run the code below may help you to understand: data have; input ID Time VariableA $ VariableB $ VariableC $; cards; 1 1 . no . 1 2 . no . 1 3 . no . 1 4 . . yes 1 5 . . no 1 6 . . yes 2 1 . yes . 2 2 . no . 2 3 . no . 2 4 . . no 2 5 . . no 2 6 . . yes ; run; proc sql; select id as _id ,1 as _time,sum(VariableB='yes') as V_t1_3,sum(VariableC='yes') as V_t4_6 from have group by id; quit;
... View more