suppose I have a dataset so that I use
proc tabulate data = a ;
class a b ;
table a, b ;
run ;
and I get
b
a 0 1
0 2 4
1 3 1
what I want is margins on *both* sides and then percentages of the total on both margins: that is:
b
a 0 1 all
0 20 40 60
1 30 10 40
all 50 50 100
I have a grim suspicion that this is not possible, but I would like to be proven wrong.
Bendix Carstensen
Senior Statistician
Steno DIabetes Center Copenhagen
Without testing, code should be like:
proc tabulate data = a ;
class a ;
var b;
table (a all),
(b all) * (pctn colpctn);
run ;
Hello,
You can try this:
proc freq data=a;
tables a*b / nocol nocum norow nofreq;
run;
I hope this helps,
FloT
@bendix wrote:
suppose I have a dataset so that I use
proc tabulate data = a ;
class a b ;
table a, b ;
run ;
and I get
b
a 0 1
0 2 4
1 3 1
what I want is margins on *both* sides and then percentages of the total on both margins: that is:
b
a 0 1 all
0 20 40 60
1 30 10 40
all 50 50 100
I have a grim suspicion that this is not possible, but I would like to be proven wrong.
Bendix Carstensen
Senior Statistician
Steno DIabetes Center Copenhagen
Provide an actual data set and what the expected results would be.
If you do not provide any additional request in the Table statement of Proc Tabulate then the result for Class variables is a count.
You can request PCTN percentage of table count, RowPctN percentage of row count and ColPctN percentage of column counts.
specific statistic requests may work. I think this is what you are looking for:
data work.a; input a b; datalines; 0 0 0 0 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 1 ; run; proc tabulate data=work.a; class a b; table a all, b*(pctn) all*colpctn ; run;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.