cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
lala
Level VII

Is there an efficient way to do this circular aggregation?

Use the big class form:
1. Starting from line 20, extract a subset of the data from this row to the previous 19 rows.
2. Classify this subset according to age and summarize height and weight.And one by one concatenation summary results.

Thanks!

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
j = 1;
For( j = 20, j <= N Row( dt ), j++,
	dt << Select Where( j - 20 < Row() <= j );
	d3 = dt << Subset( Output Table( "tab" ), Selected Rows( 1 ), selected columns( 0 ) );
	d1 = d3 << Summary(
		Sum( height ),
		Sum( weight ),
		Subgroup( age ),
		Freq( 0 ),
		Weight( 0 ),
		Link to original data table( 0 ),
		statistics column name format( "column" )
	);
	If( j == 20,
		d2 = d1;
		d2 << setName( "tmp" );
	,
		Current Data Table( d2 );
		d2 << Concatenate( Data Table( d1 ), Append to first table );
		Close( d1, nosave );
	);
	Close( d3, nosave );
);
3 REPLIES 3
txnelson
Super User

Re: Is there an efficient way to do this circular aggregation?

Structuring your JSL the way you are, you are taking advantage of some nice JMP features.  Writing JSL to create your desired output would require a lot of coding.  Below, I have made some minor adjustments to your script that might give you a little more efficient script.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
d2 = New Table( "tmp" );
k = 1;
For( k = 20, k <= N Row( dt ), k++,
	dt << Select Where( k - 20 < Row() <= k );
	d3 = dt << Subset( Output Table( "tab" ), Selected Rows( 1 ), selected columns( 0 ), private );
	d1 = d3 << Summary(
		Sum( height ),
		Sum( weight ),
		Subgroup( age ),
		Freq( 0 ),
		Weight( 0 ),
		Link to original data table( 0 ),
		statistics column name format( "column" )
	);
	
	d2 << Concatenate( Data Table( d1 ), Append to first table );
	Close( d1, nosave );
	Close( d3, nosave );
);

I changed the name of your index variable called "j".  This is to avoid possible confusion.  JMP has a function named j().  It is a better practice to avoid also having a variable named "j" too.

Jim
lala
Level VII

Re: Is there an efficient way to do this circular aggregation?

Thank Jim!

 

I want to use JMP to quickly calculate the chip peak of each stock in different cycles.It's too computationally intensive.

lala
Level VII

Re: Is there an efficient way to do this circular aggregation?

ar=[];ar=J(r,c,0);