0
votes

Hi my dataset looks something like this:

Var1    Var2    mainvar
  1      0       1
  0      0       1
  1      1       3
  0      0       2
  1      1       5
  1      1       4
  0      0       3

I want to tabulate Var1 and Var2 based on the value of mainvar (which ranges from 1 to 5) so I tried:

%let class=Var1 Var2  
proc tabulate data=x noseps missing FORMCHAR='    ';  
class &class mainvar;  
table &class;  
run;

But this is giving me the table without the data being factored by values of mainvar. Any help? Thanks!

1
You need a tables statementQuentin
Fixed! Do I need a variable statement?John Smith
It all depends what table you are trying to produce. Tables &class,mainvar will give you a frequency table with Var1 and Var2 as rows and mainvar as column.Quentin

1 Answers

0
votes

In general, I think it's best to create a reproducible example. The following works fine for me:

data example ; 
input var1 var2 mainvar ; 
cards;
  1      0       1
  0      0       1
  1      1       3
  0      0       2
  1      1       5
  1      1       4
  0      0       3
;
run;


%let class=Var1 Var2 ; 
proc tabulate data=example noseps missing FORMCHAR='    ';  
class &class mainvar;  
table &class;  
run;