Good People -
A sample program is shown below with two PROC SQLs. I would like to know how I can combine the second PROC SQL, which uses MAX and GROUP BY, with the first PROC SQL, which establishes a series of new variables.
Thanks a lot!
data got; input id question response; datalines; 1 1 0 1 2 2 1 3 1 1 4 0 2 1 1 2 2 2 2 3 3 2 4 3 3 1 0 3 2 0 3 3 0 3 4 1 ; run; proc print data=got; run;
proc sql; create table one as select id ,case when question=1 then response else 0 end as question_1 ,case when question=2 then response else 0 end as question_2 ,case when question=3 then response else 0 end as question_3 ,case when question=4 then response else 0 end as question_4 from got order by id; quit; proc print data=one; run;
proc sql; create table two as select id ,max(question_1) as m1 ,max(question_2) as m2 ,max(question_3) as m3 ,max(question_4) as m4 from one group by id; quit; proc print data=two; run;
... View more