cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
cchueng
Level III

How do I sort my dates in order?

Attached is my data table. You can see that my dates in the x-axis in my chart is not in order. How do I write a script to sort the date column before I build the chart? Notice that my date column in the table is in char.

 

cchueng_0-1707265141703.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How do I sort my dates in order?

JMP will create the JSL version of how to do the conversion, after you go through it interactively.

Here is the JSL taken from the log, after I converted the column interactively

// Change column info: vDate
Data Table( "table1" ):vDate << Data Type(
	Numeric,
	Format( "m/d/y", 10 ),
	Input Format( "m/d/y" )
) << Delete Formula << Set Modeling Type( "Continuous" ) << Set Field Width( 12 );You

 

Jim

View solution in original post

6 REPLIES 6

Re: How do I sort my dates in order?

This is a common problem when you are new to JMP. Dates should be stored as a number. Numbers are right-justified in the data table. Your date column is stored as a character string, which you can tell because it is left-justified. JMP orders character strings alphabetically. I added a column to convert your date to numeric. Open up the column info on the new Date field so you can see how this conversion is made. It could have been done on the original date column, but I thought it would be harder for you to see.

Dan Obermiller
cchueng
Level III

Re: How do I sort my dates in order?

Hello Dan,

I know how to do it in JMP. But how do you write a script in JSL to convert the vDate column from char to numeric date?

txnelson
Super User

Re: How do I sort my dates in order?

The vDate column needs to be converted to a JMP Date value.

  1. Double click on the vdate column header to open the Col Info column
  2. Click on Remove Formula
  3. Change the Data Type to Numeric
  4. Change the Modeling Type to Continuous
  5. Click on the down arrow for the Format and select     Date=>m/d/y
  6. Click on OK

Your column should now be in a JMP date format.  You can now use   Tables=>Sort   to sort the data table.

Jim
cchueng
Level III

Re: How do I sort my dates in order?

Hello Jim,

I know how to do it in JMP. But how do you write a script in JSL to convert the vDate column from char to numeric date?

txnelson
Super User

Re: How do I sort my dates in order?

JMP will create the JSL version of how to do the conversion, after you go through it interactively.

Here is the JSL taken from the log, after I converted the column interactively

// Change column info: vDate
Data Table( "table1" ):vDate << Data Type(
	Numeric,
	Format( "m/d/y", 10 ),
	Input Format( "m/d/y" )
) << Delete Formula << Set Modeling Type( "Continuous" ) << Set Field Width( 12 );You

 

Jim
cchueng
Level III

Re: How do I sort my dates in order?

Hi Jim,

A big thank you, it worked for me!