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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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