## Mann-Kendall trend significant test

Solved
Frequent Contributor
Posts: 81

# Mann-Kendall trend significant test

[ Edited ]

Hi all,

Anyone know how to do the mann-kendall trend significant test in SAS?

I could only do the following code to get the Kendall's tau coefficient, but I don't know how to test thesignificant.

proc corr data=input KENDALL noprint
OUTK=output;
Var prep;
With year;
by station;
Run;

And If I use

proc corr data=input KENDALL;
Var prep;
With year;
by station;
Run;

It seems like there has a number under the kendall's tau in the output is p-value, but I don't know how to get the results in an dataset, not only print in SAS.

Thanks SO much!

Best,

Hua

Accepted Solutions
Solution
‎10-05-2017 03:08 PM
Super User
Posts: 13,507

## Re: Mann-Kendall trend significant test

The way to get the table outputs into a data set is to use ODS OUTPUT. The trick is find the table name to use which for Proc Corr the online help has a list of tables in ODS Table Names under Details.

It looks like the table you want is the KendallCorr output.

Here is an example getting that data into a dataset.

```proc sort data=sashelp.class out=work.class;
by sex;
run;

proc corr data=work.class kendall;
var height;
with weight;
by sex;
ods output Kendallcorr= mywanteddata;
run;```

Note that the table name created by the output goes before the = and the name of the data set you want goes after.

All Replies
Solution
‎10-05-2017 03:08 PM
Super User
Posts: 13,507

## Re: Mann-Kendall trend significant test

The way to get the table outputs into a data set is to use ODS OUTPUT. The trick is find the table name to use which for Proc Corr the online help has a list of tables in ODS Table Names under Details.

It looks like the table you want is the KendallCorr output.

Here is an example getting that data into a dataset.

```proc sort data=sashelp.class out=work.class;
by sex;
run;

proc corr data=work.class kendall;
var height;
with weight;
by sex;
ods output Kendallcorr= mywanteddata;
run;```

Note that the table name created by the output goes before the = and the name of the data set you want goes after.

Frequent Contributor
Posts: 81

## Re: Mann-Kendall trend significant test

Thanks! Yes, there do has an option under ODS Table Name for outputting Kendall's coefficients .

So the results have two columns, one is the Kendall's tau coefficient, and the other is its significant (P-value), right?

Thanks for help!

Super User
Posts: 13,507

## Re: Mann-Kendall trend significant test

hua wrote:

Thanks! Yes, there do has an option under ODS Table Name for outputting Kendall's coefficients .

So the results have two columns, one is the Kendall's tau coefficient, and the other is its significant (P-value), right?

Thanks for help!

The table structure appears to have two columns for each variable appearing on the VAR statement with on coefficient and pvalue per variable so you could have Var1 PVar1 Var2 Pvar2, and the value of the column Variable would have each variable name on the with statement.

Frequent Contributor
Posts: 81

## Re: Mann-Kendall trend significant test

Yes! I got it!

BTW, Can I just have the output dataset without printing the results (the tables) on screen?

When I use "NOPRINT" option, I could not get the results, both dataset and print out tables.

Super User
Posts: 13,507

## Re: Mann-Kendall trend significant test

hua wrote:

Yes! I got it!

BTW, Can I just have the output dataset without printing the results (the tables) on screen?

When I use "NOPRINT" option, I could not get the results, both dataset and print out tables.

I'm not sure of all the technicalities of when the viewable output for tables is compiled and made available to the ods system but the was SAS has implemented this feature means that if you don't display a table you get the results for many of the tables. Of course this does still beat the old way we had to do for some of the output. We used to send the output to a file and then parse the text file created for things that weren't available directly in output data sets.

Not idea but you can close all of the ODS destinations but one, sending the print output to something other than the results window and then reactive the results window.

```ods _all_ close;
ods listing file="d:\junk.txt";
proc sort data=sashelp.class out=work.class;
by sex;
run;

proc corr data=work.class kendall;
var height;
with weight;
by sex;
ods output Kendallcorr= work.mywanteddata;
run;
ods listing close;

ods html;```

There may be slicker ways but this doesn't send anything to the results window.

☑ This topic is solved.