Subscribe Bookmark RSS Feed

accessing another table for Col Mean

waltp

Community Trekker

Joined:

May 15, 2012

Hi,

I wrote a small script in which I create a table referenced by dtSum. This table has only one row.  I want to add columns and populate them with the means of columns of another table which is referenced by dt.  The question is how do I reference the columns of the other table, dt?  The script right now looks like:

for(i = 2, i <= 9, i++,

     dtSum << New Column( "att" || Char( i ),

                    Numeric,

                    Continuous,

                    << Set Each Value( Col Mean( dt:Column(  i - 1 )  ) )

     )

);

This doesn't work.  How do I reference column i - 1 in table dt and then find its mean?  I wan to use Col Mean since I'll have to do this for other column stats.  Any suggestions are appreciated.

Thanks,

Walt

1 REPLY
Wendy_Murphrey

Joined:

Jun 23, 2011

Hello,

The Column function allows an optional data table argument.  Instead of the dt:Column syntax, try this in your Col Mean function:

    Column( dt, i-1 )

Hope that helps!

Wendy