该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


To add a new column to a data table, send a New Column message to a data table reference or use the New Column() function. The first argument, the column’s name, is required. Either enclose the name in quotation marks or specify an expression evaluating to the name.
dt = New Table( "MyData1.jmp" );
dt << New Column( "wafer" );
dt = New Table( "MyData2.jmp" );
a = "wafer";
dt << New Column( a );
dt = New Table( "MyData3.jmp" );
col = New Column( "X", Formula( Random Uniform() ) );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Ratio", Numeric, "Continuous", Formula( :height/:weight ) );
dt << New Column( "myMarkers",
Set Formula( Marker State( age - 12 ) )
myCol = dt << New Column( "Birth Date" );
To fill the column with data, use Values or its equivalent, Set Values. Include the value for each cell in a list.
dt = New Table( "My Data");
dt << New Column( "Last Name", Character, Values( {"Smith", "Jones", "Anderson"} ) );
The column can also be filled with numeric values. The following example adds a new column called Row Number to a new data table. The function N Row returns the number of rows in the table, and numeric values populate all of the rows in the column, beginning with 1.
dt = New Table( "My Data");
dt << New Column( "Last Name", Character, Values( {"Smith", "Jones", "Anderson"} ) );
dt << New Column( "Row Number",
Values( 1 :: N Row() ),
Format( "Best", 5 )
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Random", Numeric, Formula( Random Uniform() ) );
dt << New Column( "Number" );
:Number << Set Each Value( 5 );
New Column() can also be used as a built-in function, in other words, without the << (Send) command applied to the data table reference. When used in this way, the column is added to the current data table.
dt << New Column( "Address" ); // command is sent to the data table reference
New Column( "Address" ); // column is added to the current data table