このバージョンのヘルプはこれ以降更新されません。最新のヘルプは https://www.jmp.com/support/help/ja/15.2   からご覧いただけます。


「Convert Dates.jsl」は、まず、データテーブルを作成します。次に、データ入力形式を指定し、データタイプを「文字」から「数値」に、尺度を連続尺度に変更します。最後に、その列に、m/d/y形式を適用します(文字の日付の変換(変換前と変換後))。
// Create a data table with character dates.
dt = New Table( "Example",
	Add Rows( 3 ),
	New Column( "Dates",
		Character,
		Nominal,
		Set Values( {"25/01/2010", "30/09/2009", "15/12/2013"} )
	)
);
 
// Display a modal dialog for the user to confirm the format conversion.
nw = New Window( "Date Conversion",
	<<Modal,
	tb = Text Box(
		"Notice the d/m/y format of the character dates.
Click OK to convert the column to a numeric column and apply the m/d/y format."
	)
);
 
/* Apply the Numeric data type.
Specify the Informat (input format) value "d/m/y".
Specify the Format (display format) value "m/d/y".
Apply the Continuous modeling type */
col = Column( dt, "Dates" );
col << Data Type( "Numeric", Informat( "d/m/y" ), Format( "m/d/y" ) );
col << Modeling Type( "Continuous" );
 
// Display the data table in front of the script.
dt << Data Table Window();
図17.1 文字の日付の変換(変換前と変換後)
列のデータタイプを文字から数値に変更した場合は、データの入力形式の定義が重要になります。この例では、Informat( "d/m/y" )が入力形式を定義します。Format( "m/d/y" )は、表示形式を定義します。Informat()を省略した場合、Format()値は入力形式と表示形式の両方として適用されます。この例の場合は、結果としてデータが欠測値となります。
Convert Dates.jslに変更を加え、確認してみましょう。
1.
サンプルスクリプトのフォルダにある「Convert Dates.jsl」を開きます。
2.
スクリプトウィンドウを右クリックし、[行番号を表示する]を選択します。
4.
27行目で「Informat( "d/m/y" ),」を(カンマも含め)削除します。
Format( "m/d/y" )が列に適用されます。列には「01/25/2010」だけが表示されます。「30/09/2009」と「15/12/2013」は有効なm/d/y値ではないため、欠測値となります。