cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-273303%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E7%95%B6%E8%A1%8C%E6%98%AF%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%92%8C%E6%95%B8%E5%AD%97%E7%9A%84%E6%B7%B7%E5%90%88%E6%99%82%EF%BC%8C%E5%A6%82%E4%BD%95%E7%B7%A8%E5%AF%AB%E8%85%B3%E6%9C%AC%E5%B0%87%E5%88%97%E6%95%B8%E6%93%9A%E9%A1%9E%E5%9E%8B%E6%9B%B4%E6%94%B9%E7%82%BA%E6%95%B8%E5%AD%97%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-273303%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E6%9C%89%E4%B8%80%E5%80%8B%E6%95%B8%E6%93%9A%E5%88%97%EF%BC%8C%E5%85%B6%E4%B8%AD%E4%B8%80%E4%BA%9B%E8%A1%8C%E6%98%AF%E5%AD%97%E7%AC%A6%E4%B8%B2%EF%BC%8C%E4%B8%80%E4%BA%9B%E8%A1%8C%E6%98%AF%E6%95%B8%E5%AD%97%E3%80%82%E7%95%B6%E6%88%91%E6%89%8B%E5%8B%95%E5%B0%87%E6%95%B8%E6%93%9A%E9%A1%9E%E5%9E%8B%E5%BE%9E%E5%AD%97%E7%AC%A6%E8%BD%89%E6%8F%9B%E7%82%BA%E6%95%B8%E5%AD%97%E6%99%82%EF%BC%8C%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%B6%88%E5%A4%B1%EF%BC%8C%E5%8F%AA%E7%95%99%E4%B8%8B%E6%96%87%E6%9C%AC%E8%A1%8C%E3%80%82%E9%80%99%E5%B0%B1%E6%98%AF%E6%88%91%E6%83%B3%E9%80%9A%E9%81%8E%20JSL%20%E8%A4%87%E8%A3%BD%E7%9A%84%E7%A2%BA%E5%88%87%E7%B5%90%E6%9E%9C%E3%80%82%E4%BD%86%E6%98%AF%EF%BC%8C%E7%95%B6%E6%88%91%E9%81%8B%E8%A1%8C%E5%9F%B7%E8%A1%8C%E7%9B%B8%E5%90%8C%E5%8A%9F%E8%83%BD%E7%9A%84%E8%85%B3%E6%9C%AC%E6%99%82%EF%BC%8C%E5%AE%83%E4%B8%8D%E6%9C%83%E6%9B%B4%E6%94%B9%E5%88%97%E7%9A%84%E6%95%B8%E6%93%9A%E9%A1%9E%E5%9E%8B%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E9%9A%A8%E9%99%84%E7%9A%84%E5%B1%8F%E5%B9%95%E8%A8%98%E9%8C%84%E9%A1%AF%E7%A4%BA%E4%BA%86%E6%9C%AA%E4%BD%9C%E7%94%A8%E6%96%BC%E5%88%97%E7%9A%84%E8%85%B3%E6%9C%AC%E4%BB%A5%E5%8F%8A%E6%9B%B4%E6%94%B9%E6%95%B8%E6%93%9A%E9%A1%9E%E5%9E%8B%E4%BB%A5%E9%81%94%E5%88%B0%E6%89%80%E9%9C%80%E7%B5%90%E6%9E%9C%E7%9A%84%E6%89%8B%E5%8B%95%E9%81%8E%E7%A8%8B%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3C%2FP%3E%3CDIV%20class%3D%22lia-vid-container%20video-embed-center%22%3E%3CDIV%20id%3D%22lia-vid-6165037635001w960h540r297%22%20class%3D%22lia-video-brightcove-player-container%22%3E%3CVIDEO-JS%20data-video-id%3D%226165037635001%22%20data-account%3D%226058004218001%22%20data-player%3D%22default%22%20data-embed%3D%22default%22%20class%3D%22vjs-fluid%22%20controls%3D%22%22%20data-application-id%3D%22%22%20style%3D%22width%3A%20100%25%3B%20height%3A%20100%25%3B%22%3E%3C%2FVIDEO-JS%3E%3C%2FDIV%3E%26lt%3Bscript%20src%3D%22%3CA%20href%3D%22https%3A%2F%2Fplayers.brightcove.net%2F6058004218001%2Fdefault_default%2Findex.min.js%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fplayers.brightcove.net%2F6058004218001%2Fdefault_default%2Findex.min.js%3C%2FA%3E%22%26gt%3B%EF%BC%88%E5%9C%A8%E6%88%91%E7%9A%84%E8%A6%96%E9%A0%BB%E4%B8%AD%E6%9F%A5%E7%9C%8B%EF%BC%89%3C%2FDIV%3E%3CP%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-273303%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3E%E8%87%AA%E5%8B%95%E5%8C%96%E5%92%8C%E8%85%B3%E6%9C%AC%E7%B7%A8%E5%AF%AB%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E%E8%B3%AA%E9%87%8F%E5%92%8C%E5%B7%A5%E8%97%9D%E5%B7%A5%E7%A8%8B%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-273312%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%95%B6%E8%A1%8C%E6%98%AF%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%92%8C%E6%95%B8%E5%AD%97%E7%9A%84%E6%B7%B7%E5%90%88%E6%99%82%EF%BC%8C%E5%A6%82%E4%BD%95%E7%B7%A8%E5%AF%AB%E8%85%B3%E6%9C%AC%E5%B0%87%E5%88%97%E6%95%B8%E6%93%9A%E9%A1%9E%E5%9E%8B%E6%9B%B4%E6%94%B9%E7%82%BA%E6%95%B8%E5%AD%97%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-273312%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%82%A8%E7%9A%84%20JSL%20%E8%AA%9E%E6%B3%95%E4%B8%8D%E6%AD%A3%E7%A2%BA%E3%80%82%E5%AE%83%E6%87%89%E8%A9%B2%E6%98%AF%EF%BC%9A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%3Dcurrent%20data%20table()%3B%0Adt%3Aexample%20%26lt%3B%26lt%3B%20data%20type(numeric)%26lt%3B%3CFORMAT%3E%3C%2FFORMAT%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-273309%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E7%95%B6%E8%A1%8C%E6%98%AF%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%92%8C%E6%95%B8%E5%AD%97%E7%9A%84%E6%B7%B7%E5%90%88%E6%99%82%EF%BC%8C%E5%A6%82%E4%BD%95%E7%B7%A8%E5%AF%AB%E8%85%B3%E6%9C%AC%E5%B0%87%E5%88%97%E6%95%B8%E6%93%9A%E9%A1%9E%E5%9E%8B%E6%9B%B4%E6%94%B9%E7%82%BA%E6%95%B8%E5%AD%97%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-273309%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E9%80%99%E5%80%8B%E4%BE%8B%E5%AD%90%E5%B1%95%E7%A4%BA%E7%9E%AD%E5%A6%82%E4%BD%95%E5%81%9A%E5%88%B0%E9%80%99%E4%B8%80%E9%BB%9E%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20to%20Here(%201%20)%3B%0A%0Adt%20%20%3D%20Open(%20%22%24SAMPLE_DATA%2FBig%20Class.jmp%22%20)%3B%0A%0Atest%20%3D%20dt%20%26lt%3B%26lt%3B%20New%20Column(%20%22Test%22%2C%20Character%2C%20Nominal%2C%0A%20Values(%7B%0A%20%20%22Mark%22%2C%0A%20%20%22Jane%22%2C%0A%20%20%225.37%22%2C%0A%20%20%223.14%22%2C%0A%20%20%22Linda%22%2C%0A%20%20%221.732%22%0A%20%7D)%0A)%3B%0A%0AWait(%202%20)%3B%0A%0Atest%20%26lt%3B%26lt%3B%20Set%20Data%20Type(%20Numeric%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
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.

 

(view in My Videos)

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

Recommended Articles