cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to use Accelerated Life Testing (ALT) to evaluate reliability. Register for June 5 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
bzanos
Level III

How to Append One Report from Data Table A followed by Another Report from Data Table B through For Loop

I have two different data tables, A and B. There is one column from each data table has similar variable.

I create subset from each data table A and B by column that has similar variable using separate For loop to create table report and append it into one new window.

I notice that all the table reports created from subset data table A are appended into new window and followed by all the table reports from subset data table B. 

What I want is to append one table report from subset data table A followed by table report from subset data table B for each variable level.

 

How should I write the code?

 

I am using Big Class and Big Class Families data set as an example to illustrate this.

dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA/Big Class Families.jmp" );

vb = V List Box();
listdt1 = {};
listdt2 = {};
coldt1 = Column (dt1, "age");
coldt2 = Column (dt2, "age");
colleveldt1 = Associative Array(coldt1) << Get Keys;
colleveldt2 = Associative Array(coldt1) << Get Keys;

For (i=1, i <=N Items(colleveldt1), i++,
	dt1row = dt1 << Get Rows Where(:age == colleveldt1[i]);
	listdt1[i] = dt1 << Subset(Rows(dt1row));
	tb = listdt1[i]<< Get As Report;
	vb << Append (Table Box(tb));

);
	
For (i=1, i <=N Items(colleveldt2), i++,
	dt2row = dt2 << Get Rows Where(:age == colleveldt2[i]);
	listdt2[i] = dt2 << Subset(Rows(dt2row));
	tb = listdt2[i]<< Get As Report;
	vb << Append (Table Box(tb));
	
	
);

New Window("Report", vb);

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to Append One Report from Data Table A followed by Another Report from Data Table B through For Loop

A simple moving of the JSL gets you what you want

Names Default To Here( 1 );

dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA/Big Class Families.jmp" );

vb = V List Box();
listdt1 = {};
listdt2 = {};
coldt1 = Column (dt1, "age");
coldt2 = Column (dt2, "age");
colleveldt1 = Associative Array(coldt1) << Get Keys;
colleveldt2 = Associative Array(coldt1) << Get Keys;

For (i=1, i <=N Items(colleveldt1), i++,
	dt1row = dt1 << Get Rows Where(:age == colleveldt1[i]);
	listdt1[i] = dt1 << Subset(Rows(dt1row),invisible);
	tb = listdt1[i]<< Get As Report;
	vb << Append (Table Box(tb));
dt2row = dt2 << Get Rows Where(:age == colleveldt2[i]);
	listdt2[i] = dt2 << Subset(Rows(dt2row),invisible);
	tb = listdt2[i]<< Get As Report;
	vb << Append (Table Box(tb));
);

New Window("Report", vb);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: How to Append One Report from Data Table A followed by Another Report from Data Table B through For Loop

A simple moving of the JSL gets you what you want

Names Default To Here( 1 );

dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA/Big Class Families.jmp" );

vb = V List Box();
listdt1 = {};
listdt2 = {};
coldt1 = Column (dt1, "age");
coldt2 = Column (dt2, "age");
colleveldt1 = Associative Array(coldt1) << Get Keys;
colleveldt2 = Associative Array(coldt1) << Get Keys;

For (i=1, i <=N Items(colleveldt1), i++,
	dt1row = dt1 << Get Rows Where(:age == colleveldt1[i]);
	listdt1[i] = dt1 << Subset(Rows(dt1row),invisible);
	tb = listdt1[i]<< Get As Report;
	vb << Append (Table Box(tb));
dt2row = dt2 << Get Rows Where(:age == colleveldt2[i]);
	listdt2[i] = dt2 << Subset(Rows(dt2row),invisible);
	tb = listdt2[i]<< Get As Report;
	vb << Append (Table Box(tb));
);

New Window("Report", vb);
Jim
bzanos
Level III

Re: How to Append One Report from Data Table A followed by Another Report from Data Table B through For Loop

Thanks.

Recommended Articles