日付時間値によるサブセットデータ抽出
「Select Where Using Dates.jsl」は、出発日(Departure Date)の列をもとに、MDY関数を利用して、特定の期間だけを含んだデータを作成します。そして、そのデータから、正味費用(Net Costs)の曜日(Departure Day of Week)ごとの平均を求めています(元のテーブルと最終的な要約テーブル)。
/* How can you work with dates in JSL? JMP provides a number of formats
that you can use to make comparisons and then subset data based on the date.
*/
hdt = Open( "$SAMPLE_DATA/Travel Costs.jmp" );
/* Apply the Date MDY format to Departure Date values and then select only
February dates.*/
hdt << Select Where(
(Date MDY( 02, 01, 2007 ) <= :Departure Date < Date MDY( 03, 1, 2007 ))
);
/* Subset the selected rows into two tables: one table contains February
departure dates, the other contains all data for those departure dates.*/
nt1 = hdt << Subset( Columns( :Departure Date ),
Output Table Name( "February Departure Date" ) );
nt2 = hdt << Subset( Output Table Name( "February Data" ) );
/* Create a summary table, grouping mean cost by day of week that departure
took place.*/
sumDt = nt2 << Summary(
Group( :Departure Day of Week ),
Mean( :Net Cost ),
Output Table Name( "Mean Net Cost by Departure Date" )
);
図17.2 元のテーブルと最終的な要約テーブル