BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SAS-questioner
Obsidian | Level 7

Hi, I have a data like below:

person      i1 i2 i3 i4
    1       1  2  3  4
    2       3  2  4  1
    3       2  1  3  4
    4       4  1  2  3

Each person needs to rank the four things (i1, i2, i3, i4), for example, if the person thinks i4 is the best, then put 1 for i4; if the person thinks i3 is the second best, the put 2 for i3;  if the person think i1 is the third best, the put 3 for i1; if the person think i2 is the worst, then put 4 for i2. So the rank of four things (i1-i4) for this person is 3 4 2 1.

 

I want to compute Kendall's W for the data like this, do you know the code for SAS? I checked online, PROC FREQ and PROC CORR can be used, but the data seems different from mine. Does anyone know how to do it? Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @SAS-questioner,

 

Here's the code you can use once you have compiled the %MAGREE macro recommended by StatDave:

data have;
input person i1 i2 i3 i4;
cards;
1 1 2 3 4
2 3 2 4 1
3 2 1 3 4
4 4 1 2 3
;

proc transpose data=have name=item out=want(rename=(col1=rank));
by person;
var i1-i4;
run;

%magree(data=want,
        items=item, raters=person, response=rank,
        stat=kendall, options=wcl)

Main part of the output:

Kendall's Coefficient of Concordance for ordinal response

Coefficient                                                    Lower         Upper
     of                 Num    Den              Standard    Confidence    Confidence
Concordance      F       DF     DF    Prob>F      Error        Limit         Limit

    0.3        1.286    2.5    7.5    0.3406     0.34233         0          0.97095

View solution in original post

4 REPLIES 4
StatDave
SAS Super FREQ

As always with questions of statistic availability, check the link to the list of Frequently Asked-for Statistics (FASTats) at the top of the Statistical Procedures Community page. You will find Kendall's coefficient of concordance there pointing to a macro that can be used to compute it.

FreelanceReinh
Jade | Level 19

Hi @SAS-questioner,

 

Here's the code you can use once you have compiled the %MAGREE macro recommended by StatDave:

data have;
input person i1 i2 i3 i4;
cards;
1 1 2 3 4
2 3 2 4 1
3 2 1 3 4
4 4 1 2 3
;

proc transpose data=have name=item out=want(rename=(col1=rank));
by person;
var i1-i4;
run;

%magree(data=want,
        items=item, raters=person, response=rank,
        stat=kendall, options=wcl)

Main part of the output:

Kendall's Coefficient of Concordance for ordinal response

Coefficient                                                    Lower         Upper
     of                 Num    Den              Standard    Confidence    Confidence
Concordance      F       DF     DF    Prob>F      Error        Limit         Limit

    0.3        1.286    2.5    7.5    0.3406     0.34233         0          0.97095
Ksharp
Super User

Check   @Rick_SAS   blogs:

On computing Kendall's tau statistic in SAS - The DO Loop

Weak or strong? How to interpret a Spearman or Kendall correlation - The DO Loop (sas.com)

 

data have;
input person i1 i2 i3 i4;
cards;
1 1 2 3 4
2 3 2 4 1
3 2 1 3 4
4 4 1 2 3
;

proc transpose data=have name=item out=temp(rename=(col1=rank));
by person;
var i1-i4;
run;
proc freq data=temp noprint;
table item*rank/out=want sparse;
run;




proc freq data=want;
   weight count;
   tables item*rank / measures CL norow nocol nopercent;
run;

Ksharp_0-1709607778587.png

 

Ksharp
Super User

As Freelance said, If you are looking for Kendall's W. Check %magree macro.

 

Ksharp_0-1709622525454.png

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 596 views
  • 2 likes
  • 4 in conversation