Programming the statistical procedures from SAS

Question about correspondence analysis

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

Question about correspondence analysis

[ Edited ]

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!


Accepted Solutions
Solution
‎12-13-2016 02:20 PM
SAS Super FREQ
Posts: 3,547

Re: Question about correspondence analysis

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


All Replies
Solution
‎12-13-2016 02:20 PM
SAS Super FREQ
Posts: 3,547

Re: Question about correspondence analysis

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;
Contributor
Posts: 27

Re: Question about correspondence analysis

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! 

 

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 121 views
  • 2 likes
  • 2 in conversation