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

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

 

View solution in original post

5 REPLIES 5
ballardw
Super User

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.

 

hua
Obsidian | Level 7 hua
Obsidian | Level 7

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!

ballardw
Super User

@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.

hua
Obsidian | Level 7 hua
Obsidian | Level 7

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!

ballardw
Super User

@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.

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 7145 views
  • 1 like
  • 2 in conversation