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

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Discussion stats
  • 4 replies
  • 606 views
  • 0 likes
  • 2 in conversation