BookmarkSubscribeRSS Feed
nitaki
Calcite | Level 5

I have a simple data like this:

 

Types[A-D]  Points[1-5]

A                  4

B                  5

A                  2

C                 4

D                 1

A                  5

...                 ...

 

 

I need to create a table where there are frequencies of each type-points pair with rowpctns plus total mean and std for each type:

 

         1           2       ...       Mean      Std

      N  %     N  %    ...        

A    3   12    4  16   ...        3.2          0.3
B    4   16    1   5    ...        2             0.5
C    1   5      4   16  ...        14           0.2

...

 

I can create both result tables separately with proc tabulate depending on if I treat points as class or analysis variable. Yet, I cannot wrap my head around how to create the table I described above. How should I approach this?

1 REPLY 1
Ksharp
Super User

Opps. I think I made a mistake.

 

data have;
input type $ point;
cards;
A                  4
B                  5
A                  2
C                 4
D                 1
A                  5
;
proc freq data=have noprint;
table type*point/out=temp list;
run;

proc tabulate data=temp ;
class type point;
var count;
table type ,point*count=' '*(sum='n'*f=f10. rowpctsum='%') count=' '*(mean std);
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 474 views
  • 0 likes
  • 2 in conversation