BookmarkSubscribeRSS Feed
sharuu_00
Calcite | Level 5

 

 

How do I count for each variable in PROC REPORT porcedure? I have tried n, proc means

 

so, here is my final dataset:

 

x1.   x2    x3.   x4

1       0.    1.     1

0.      0.    1.     1

1.      1.    0.     1

1.      0.    0.     0

1.      0.     0.    0

 

 

 

I need to count how many ones for each variable. and produce the proc report as:

 

 

       x1.   x2.  x3.  x4

n.     4.     1.    2.    3

 

4 REPLIES 4
Ksharp
Super User
data have;
input x1   x2    x3   x4;
cards;
1       0.    1.     1
0.      0.    1.     1
1.      1.    0.     1
1.      0.    0.     0
1.      0.     0.    0
;

proc report data=have nowd;
column  x x1 x2 x3 x4;
define x/computed ' ';
define x1/analysis sum;
define x2/analysis sum;
define x3/analysis sum;
define x4/analysis sum;
compute x/character length=2;
x='n';
endcomp;
run;
sharuu_00
Calcite | Level 5

Thank you for the tip and help. It worked.  And, when I add DISPLAY variables in DEFINE statement that sum goes away.

 

How can I display my variables.  Thanks!

Ksharp
Super User

That was supposed to do .

What do you want ? Post your output .

sharuu_00
Calcite | Level 5

Thanks for the quick reply!

 

I have added "DISPLAY variables" after "analysis options" and it did not worked. But, when I add DISPLAY before the analysis Then it works.  It displays varibles ans the sum. Thanks so much