- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Thanks for your patience!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
Thanks for your patience!
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.