Hellow, how the number of options available should be calculated in SAS? My data:

Obs Density$    P1  P2  P3  P4
1   0500_0600   0   0   0   0
2   0500_0600   0   0   0   0
3   0500_0600   0   0   0   0
4   0500_0600   0   0   0   0
5   0500_0600   1   3   8   4
6   0500_0600   1   3   8   4
7   0500_0600   1   3   11  4
8   0500_0600   1   3   11  4
9   0500_0600   1   3   11  4
10  0500_0600   1   3   14  4
11  0500_0600   1   3   14  4
12  0500_0600   1   3   14  4
13  0500_0600   1   3   14  4
14  0500_0600   1   3   14  4
15  0500_0600   1   3   17  4
16  0500_0600   1   4   8   4
17  1500_1600   1   9   8   4
18  1500_1600   1   9   8   4
19  1500_1600   3   3   8   2
20  1500_1600   3   4   8   2

I need to get the following table:

Obs Density     P1  P2  P3  P4  Count
1   0500_0600   0   0   0   0   4
2   0500_0600   1   3   8   4   2
3   0500_0600   1   3   11  4   3
4   0500_0600   1   3   14  4   5
5   0500_0600   1   3   17  4   1
6   0500_0600   1   4   8   4   1
7   1500_1600   1   9   8   4   2
8   1500_1600   3   3   8   2   1
9   1500_1600   3   4   8   2   1

Thank you

I can't find what function I can use.

1

There are 1 best solutions below

0
Kiran On

you can do this in many ways, below are couple of ways. In below code t is your initial table name.

proc sql;
create table t1 as
select density,p1,p2,p3,p4, count(*) as cnt
from t
group by 1,2,3,4,5;
quit;




proc means data=t nway noprint;
class _all_;
output out=t1 (drop=_type_ rename=(_freq_=count));
run;