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

Hi experts,

I just start to use SAS and have a task to create a crosstab table. The table 1 below is the dataset with all dummy variables and how could I use SAS to generate the table like table 2? Table 2 shows that how many observation have both A&B or B&C or A&C.

1.png2.png

1 ACCEPTED SOLUTION

Accepted Solutions
sotojcr
Obsidian | Level 7


Hi!
Do you know anything about statistics?
in this case the crosstab  =  table of the sums of squares and crossproducts he sums of squares and crossproducts 

data TEST;
input A B C;
datalines;
1 0 1
0 1 0
0 0 1
1 0 1
1 1 1
0 1 1
1 0 1
1 0 0
0 1 0
0 1 1
;
run;

proc corr data=TEST SSCP  outp=SSCP noprint;
var A B C;
run;
 
or a cleaner code (without unnecessary columns)
 
proc corr data=TEST SSCP  outp=SSCP(drop = INTERCEPT where=(_TYPE_ ="SSCP" and _NAME_ ne "Intercept")) noprint;
var A B C;
run;

View solution in original post

3 REPLIES 3
sotojcr
Obsidian | Level 7


Hi!
Do you know anything about statistics?
in this case the crosstab  =  table of the sums of squares and crossproducts he sums of squares and crossproducts 

data TEST;
input A B C;
datalines;
1 0 1
0 1 0
0 0 1
1 0 1
1 1 1
0 1 1
1 0 1
1 0 0
0 1 0
0 1 1
;
run;

proc corr data=TEST SSCP  outp=SSCP noprint;
var A B C;
run;
 
or a cleaner code (without unnecessary columns)
 
proc corr data=TEST SSCP  outp=SSCP(drop = INTERCEPT where=(_TYPE_ ="SSCP" and _NAME_ ne "Intercept")) noprint;
var A B C;
run;
PeterLee1012
Calcite | Level 5

Thank you so much for your response, that solve the problem perfectly.

PeterLee1012
Calcite | Level 5

So do I have any chance to reorder the SSCP table? Like reorder A B C by their frequency.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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