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

Hi 

I posted a question eariler today about different statistical methods to examine relationship between binary/nominal variables in my dataset. Someone suggested correspondence analysis and here's the SAS code I used. 

 

data tab1;
input sleep_place$1-12 co_sleep$13-16 onback ontummy onside;
datalines;
SafePlace No 17 26 6
SafePlace Yes 1 2 1
UnsafePlace No 14 10 4
UnSafePlace Yes 44 27 20
;


data tab2;set tab1;
length newvar $ 28;
newvar=cat(sleep_place,co_sleep);run;

 

ods graphics on;
proc corresp data=tab2 plot;
var onback ontummy onside;
id newvar;run;
ods graphics off;

 

My question is: Does it make sense to have one combined ID variable?  Also, is there anything I should add/delete/change? 

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

That choice of ID variable doesn't seem to be helpful. Try combining them, like this:

 

data tab1;
length ID $16;
input sleep_place $1-12 co_sleep  $13-16 onback ontummy onside;
ID = catc(sleep_place,co_sleep);
datalines;
SafePlace   No  17 26 6
SafePlace   Yes 1 2 1
UnsafePlace No  14 10 4
UnSafePlace Yes 44 27 20
;

proc corresp data=tab1;
var onback ontummy onside;
id ID;
run;

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

That choice of ID variable doesn't seem to be helpful. Try combining them, like this:

 

data tab1;
length ID $16;
input sleep_place $1-12 co_sleep  $13-16 onback ontummy onside;
ID = catc(sleep_place,co_sleep);
datalines;
SafePlace   No  17 26 6
SafePlace   Yes 1 2 1
UnsafePlace No  14 10 4
UnSafePlace Yes 44 27 20
;

proc corresp data=tab1;
var onback ontummy onside;
id ID;
run;
jhs2171
Obsidian | Level 7

Hi Rick, 

 

Thank you for your comment! After I posted my question, I realized it didn't really make sense to use only one of the variables as ID, so I combined the first two and made the change to my original posting! I just tried what you suggested, and it returned the same result so thank you for the confirmation!! You been super helpful today! 

 

 

 

sas-innovate-2024.png

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.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1289 views
  • 3 likes
  • 2 in conversation