Hi all,
I'm trying to copy the column names, data types, modeling types and formats from one table into a new one, but when I try to set the column format, it never takes and just reverts to "Best". I've been banging my head against this for a while and am completely stumped why it's not working. Below is my code and the resulting output that shows the column format is valid but just doesn't stick. There are no errors reported in the log. Can anyone see what I'm doing wrong?
summaryTable = New Table( "Results Summary" );
colNames = data << Get Column Names( string );
For( i = 1, i <= N Items( colNames ), i++,
colType = Column( data, colNames[i] ) << Get Data Type;
colModel = Column( data, colNames[i] ) << Get Modeling Type;
colFormat = Column( data, colNames[i] ) << Get Format;
Show( colNames[i] );
Show( colType );
Show( colModel );
Show( colFormat );
newCol = summaryTable << New Column( colNames[i] );
newCol << Data Type( colType ) << Modeling Type( colModel );
If( colType != "Character",
newCol << Format( colFormat );
Show( newCol << Get Format );
);
);
colNames[i] = "Label";
colType = "Character";
colModel = "Nominal";
colFormat = Format("Best");
colNames[i] = "Start_Time";
colType = "Numeric";
colModel = "Continuous";
colFormat = Format("m/d/y h:m:s", 23, 0);
newCol << Get Format = Format("Best", 10);
colNames[i] = "End_Time";
colType = "Numeric";
colModel = "Continuous";
colFormat = Format("m/d/y h:m:s", 23, 0);
newCol << Get Format = Format("Best", 10);
Bonus follow-up question: I can only seem to set the column data and modeling types using the above code where I set the types after the column is initialized. When I try to execute the below line the columns simply don't initialize, why not?
newCol = summaryTable << New Column( colNames[i], colType, colModel );