BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
svzplayer
Fluorite | Level 6

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
Ksharp
Super User
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;

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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
svzplayer
Fluorite | Level 6

I am asking how to turn this into another SAS data set which is set up like a contingency table, sorry for ambiguity.

Ksharp
Super User
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;
svzplayer
Fluorite | Level 6
Thanks!

sas-innovate-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 677 views
  • 2 likes
  • 3 in conversation