Hi,
Please help me with SAS code for 3 ways contingency table. I want my table to look like below. Any help would be appreciated.
For future reference: When pasting a log file, or an output from a procedure, click on the {i} icon and paste your text into that window.
Try something like this:
proc report data=have;
columns x1 x2 x3;
define x1/group "Label for X1";
define x2/group "Label for X2";
define x3/across "Label for X3";
run;
The basic form of the analysis is:
proc freq data=have;
tables x1*x2*x3;
run;
PROC FREQ has lots of options: https://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=statug&docsetTarget=statug_fr...
Also, PROC REPORT ought to be able to do this.
For future reference: When pasting a log file, or an output from a procedure, click on the {i} icon and paste your text into that window.
Try something like this:
proc report data=have;
columns x1 x2 x3;
define x1/group "Label for X1";
define x2/group "Label for X2";
define x3/across "Label for X3";
run;
You want PROC TABULATE then instead:
proc tabulate data=have;
class def_race victim_race death_penalty;
table def_race="Defandant's Race"*victim_race="Victim's Race" , death_penalty="Death Penalty";
run;
@Kyra wrote:
Hi,
Please help me with SAS code for 3 ways contingency table. I want my table to look like below. Any help would be appreciated.
Thank you very much. This code also worked.
one further question-
Is it possible to do chisq/fisher's for these kind of 3 way contingency tables.
Thanks,
Actually....it can't it does two way tables. Not sure what you would do for a three way table, maybe catmod or proc logistic I suspect.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.