cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

Unable to Convert Character Column to Continuous Date Format Using JSL

Hello,

I have an input table with a column TEST_START_DATETIME that JMP initially recognizes as a Character/Nominal Data/Modeling Type as shown below.

ClassDendrogram_0-1766798968667.png

I can set this column as a continuous date/time format type using the Column Info dialog.

ClassDendrogram_1-1766799077820.png

Note the text is shifted to the right, indicating it's a cell.

ClassDendrogram_2-1766799137209.png

 

However, when I try to do this in JSL I get an empty column. It looks like it converted the column to numeric type before applying the format type, causing it to get deleted.

 

dt = Current Data Table();

dt << Begin Data Update;
	dt:TEST_START_DATETIME << Data Type("Numeric");
	dt:TEST_START_DATETIME << Modeling Type("Continuous");
	dt:TEST_START_DATETIME << Input Format("Format Pattern", "<YYYY>_<MM>_<DD>-<hh24>_<mm>_<ss>");
	dt:TEST_START_DATETIME << Format("Format Pattern", "<YYYY>_<MM>_<DD>-<hh24>_<mm>_<ss>");
dt << End Data Update;

What could I be doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Unable to Convert Character Column to Continuous Date Format Using JSL

You are doing << Data Type("Numeric") first -> it will be converted to number too early. Do it manually in JMP, look at the log and copy the script.

// Change column info: Column 1
Data Table("Untitled"):Column 1 << Set Data Type(
	Numeric,
	Format("Format Pattern", "<DD><-><MM><-><YYYY> <hh24><::><mm><::><ss>", 19, 0),
	Input Format("Format Pattern", "<DD><-><MM><-><YYYY> <hh24><::><mm><::><ss>", 0)
) << Set Modeling Type("Continuous");

Scripting Index also has an example on how to change data type while applying formatting

jthi_0-1766813326876.png

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Unable to Convert Character Column to Continuous Date Format Using JSL

You are doing << Data Type("Numeric") first -> it will be converted to number too early. Do it manually in JMP, look at the log and copy the script.

// Change column info: Column 1
Data Table("Untitled"):Column 1 << Set Data Type(
	Numeric,
	Format("Format Pattern", "<DD><-><MM><-><YYYY> <hh24><::><mm><::><ss>", 19, 0),
	Input Format("Format Pattern", "<DD><-><MM><-><YYYY> <hh24><::><mm><::><ss>", 0)
) << Set Modeling Type("Continuous");

Scripting Index also has an example on how to change data type while applying formatting

jthi_0-1766813326876.png

 

-Jarmo

Re: Unable to Convert Character Column to Continuous Date Format Using JSL

Thanks! I looked at the output log, copied the same script and it now works when run as a standalone script. I didn't know that the log window could be used to see commands invoked through GUI in real time.

dt = Current Data Table();


dt:TEST_START_DATETIME << Set Data Type(
		Numeric,
		Format( "Format Pattern", "<YYYY>_<MM>_<DD>-<hh24>_<mm>_<ss>", 19, 0 ),
		Input Format( "Format Pattern", "<YYYY>_<MM>_<DD>-<hh24>_<mm>_<ss>", 0 )
	) << Set Modeling Type( "Continuous" );

Recommended Articles