Even if the definitions Mann-Kendall test statistic and the Kendall Tau b often is described in different terms (from time series and correlation perspectives, respectively), they are essentially the same as far as I can tell.
Below is a script I wrote quite long ago. It calculates and shows the Theil's slope and performs the Mann-Kendall test. A parametric linear regression line is shown in the plot just for comparision. I planned to generalize the script by include a "By" function as well as the posibilty to account for seasonal patterns. But I have not had the time to realize those plans yet. I hope this will give you some ideas.
dt = Current Data Table();
dlg = Column Dialog(
"Estimate Theil slope and Kendall Tau from Data Table " ||
Char( dt << get name ),
Ys = ColList( "Select Y",
maxcol( 1 ),
mincol( 1 ),
Datatype( numeric )
),
Xs = ColList( "Select X",
maxcol( 1 ),
mincol( 1 ),
Datatype( numeric )
),
Group = ColList( "By (not working)", maxcol( 1 ) )
);
colY = Column( dt, dlg["Ys"] );
colX = Column( dt, dlg["Xs"] );
colGroup = Column( dt, dlg["Group"] );
//Calculation of Theil slope
n = N Rows( dt );
slopes = J( n, n, . );
For( i = 1, i < n, i++,
For( j = i + 1, j <= n, j++,
slopes[i, j] = (colY[j] - colY[i]) / (colX[j] - colX[i])
)
);
theil = Quantile( 0.5, slopes );
//Kendall's Tau b to test if slope differs from zero
mv = Multivariate(
Y( colY, colX ),
Scatterplot Matrix(0),
Correlations multivariate(0),
Kendall's Tau( 1 )
);
//Plot data and add linear regression and Theil's slope
biv = Bivariate(
Y( colY ),
X( colX ),
Fit Line( {Line Color( "Red" )} ),
Fit Special( Slope( theil ), {Line Color( "Green" )} ),
invisible
);
rbiv = biv << report;
rbiv["Linear Fit"] << close all like this;
rbiv[Outline Box( 7 )] << set title( "Theil's Slope" );
db = Report( mv )["Multivariate"] << parent;
db << prepend( rbiv );
db[Text Box( 4 )] << set text( "Theil's Slope" );
rbiv << close window;