🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 05-25-2020 05:50 AM
(1444 views)
Hello,
I need help creating a contingency table from a dataset. I have a dataset in a form:
A X1 n1
A X2 n2
B X1 n3
B X2 n4 , where ni is number of observations in a group
and I need to make a contingency table from this dataset. How can I do that?
Many thanks!
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data have;
input (a b) ($) c;
cards;
A X1 11
A X2 2
B X1 3
B X2 24
;
run;
options missing='0' ;
proc transpose data=have out=want(drop=_:);
by a ;
id b;
var c;
run;
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Are you asking how to turn this into another SAS data set which is set up like a contingency table? Or are you asking for output (results window, such as html) that looks like a contingency table?
--
Paige Miller
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am asking how to turn this into another SAS data set which is set up like a contingency table, sorry for ambiguity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data have;
input (a b) ($) c;
cards;
A X1 11
A X2 2
B X1 3
B X2 24
;
run;
options missing='0' ;
proc transpose data=have out=want(drop=_:);
by a ;
id b;
var c;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks!