Choose Language Hide Translation Bar
Highlighted
user8421
Level I

How to script changing column data type to Numeric when the rows are a mix of string and numbers

I have a data column where some rows are string and some rows are numbers.  When I manually convert the Data Type from Character to Numeric, the strings disappear leaving only the text rows.  This is the exact result I would like to replicate via JSL.  However when I run a script that performs the same functions it does not change the Data Type for the column.

Attached is a screen recording showing both the script not acting on the column and the manual process of changing the Data Type with desired result.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: How to script changing column data type to Numeric when the rows are a mix of string and numbers

Your JSL syntax is incorrect.  It should be:

dt=current data table();
dt:example << data type(numeric)<<format("Best", 12) <<
modeling type(continuous);
Jim

View solution in original post

2 REPLIES 2
Highlighted

Re: How to script changing column data type to Numeric when the rows are a mix of string and numbers

This example shows how to do it.

 

Names Default to Here( 1 );

dt  = Open( "$SAMPLE_DATA/Big Class.jmp" );

test = dt << New Column( "Test", Character, Nominal,
	Values({
		"Mark",
		"Jane",
		"5.37",
		"3.14",
		"Linda",
		"1.732"
	})
);

Wait( 2 );

test << Set Data Type( Numeric );
Learn it once, use it forever!
Highlighted
txnelson
Super User

Re: How to script changing column data type to Numeric when the rows are a mix of string and numbers

Your JSL syntax is incorrect.  It should be:

dt=current data table();
dt:example << data type(numeric)<<format("Best", 12) <<
modeling type(continuous);
Jim

View solution in original post

Article Labels