该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


Convert Dates.jsl creates a data table, specifies the data input format, changes the column to a numeric continuous column, and applies the m/d/y format (图 17.1).
dt = New Table( "Example",
New Column( "Dates",
Set Values( {"25/01/2010", "30/09/2009", "15/12/2013"} )
nw = New Window( "Date Conversion",
<<Modal,
tb = Text Box(
"Notice the d/m/y format of the character dates.
col = Column( dt, "Dates" );
col << Data Type( "Numeric", Informat( "d/m/y" ), Format( "m/d/y" ) );
col << Modeling Type( "Continuous" );
dt << Data Table Window();
图 17.1 Converting Character Dates (Before and After)
When you change the column’s data type from character to numeric, defining the format in which the data were entered is important. In this example, Informat( "d/m/y" ) defines the input format. Format( "m/d/y" ) defines the new display format. If Informat() is omitted, the Format() value is applied as both the input and display format. This results in missing values for some data.
Modify Convert Dates.jsl to see for yourself.
1.
Open Convert Dates.jsl from the sample scripts folder.
4.
On line 27, delete Informat( "d/m/y" ), (including the comma).
Format( "m/d/y" ) is applied to the column. Only "01/25/2010" appears in the column. The other values are missing; "30/09/2009" and "15/12/2013" are not valid m/d/y values.