cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
user8421
Level II

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
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

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 );
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