I have a dataset as follows:
ID |----A---|-----B--| TIME
1--|----1---| ----0---| q1
2--|----0---| ----1---| q2
3--|----0---| ----0---| q3
4--|----1---| ----1---| q4
where 1 means present and 0 means not present
How can I write proc statement to output a frequency table as follows:
TIME
Q1 Q2 Q3 Q4 TOTAL
A
0 ---10---------------20---------------5-------------------3
1----5----------------35---------------2--------------------1
B
0-------1------------2-------------------32-------------------2
1------6--------------3-------------------2-------------------3
Thanks
PROC TABULATE is better here as you have a bit more control over the table structure especially with multiple variables.
Something like this - untested because your data is in an unusable form.
proc tabulate data=have;
class a b time;
table a b, (time all='Total');
run;