Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
njmp
Level I

Adding new columns to a data table

i create a table and try add two aolumns in jsl as follows:

Test = New Table( "Test" );
Test << New Column( "Ident", Character, Continuous, Format( "Best", 8 ), set values( identifiers ) );
Test << New Column( "Value", Numeric, Continuous, Format( "Best", 8 ), set values( values ) );

identifiers - is a list of caharacters

values - a a list of matching numbers.

using the format above, creates only ident column , populates with values and stops before adding the second column. no report of an error.

(if i run the command latter manually it adds also Value column and the values.

 

if i use a slightly different format (below), no issues and both columns are created and populated with the values:

Test=new table("Test");
Test<<new column("Value",Numeric,Continuous,format("Best",8),set values(values));
Test<<new column("Ident",Character,Continuous,format("Best",8),set values(identifiers));

any explanation to this behavior?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: Adding new columns to a data table

A column that has is of Data Type, "Character", can only have a Modeling Type of "Nominal".  Also, a Format definition for a Character column can not be specified.  The script below is a modification of your script that runs without error

Names Default To Here( 1 );

identifiers = {"a", "b", "c"};
values = {1, 2, 3};

Test = New Table( "Test" );
Test <<
New Column( "Ident",
	Character,
	set values( identifiers )
);
Test <<
New Column( "Value",
	Numeric,
	Continuous,
	Format( "Best", 8 ),
	set values( values )
);
Jim

View solution in original post

3 REPLIES 3
Highlighted
txnelson
Super User

Re: Adding new columns to a data table

A column that has is of Data Type, "Character", can only have a Modeling Type of "Nominal".  Also, a Format definition for a Character column can not be specified.  The script below is a modification of your script that runs without error

Names Default To Here( 1 );

identifiers = {"a", "b", "c"};
values = {1, 2, 3};

Test = New Table( "Test" );
Test <<
New Column( "Ident",
	Character,
	set values( identifiers )
);
Test <<
New Column( "Value",
	Numeric,
	Continuous,
	Format( "Best", 8 ),
	set values( values )
);
Jim

View solution in original post

Highlighted
njmp
Level I

Re: Adding new columns to a data table

Thanks a lot:)
Highlighted
Jacksmith12
Level IV

Re: Adding new columns to a data table

Hi @txnelson,

 

Thanks for your help. 

2nd file doesn't have Minimum Age Column. How can I create the 2nd column with name "Minimum Age" and then run the above script?

Article Labels

    There are no labels assigned to this post.