cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

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

Reference Subset Data Tables Created from a Loop

I'm having some issues referencing subset data tables made from a loop. The loop works fine and creates data tables named cond1, cond2, etc, but if I try to reference those newly created tables in later code, the script log says it can't find them. Oddly enough if I run my script peicewise, it works just fine. 

 

for(i=1, i<=10, i++,
     Original_table << select where(:Sorting Condition == i);

     dti = Original_table << Subset(
          Output table("cond"||char(i)),
          Selected Rows( 1 ),
          Selected columns only( 0 )
);
);

datatable("cond"||char(i)) << new column("random", numeric, continuous, formula(round(Random Uniform(1,150)),0));

2 REPLIES 2

Re: Reference Subset Data Tables Created from a Loop

It might be simpler to insert the new data table reference dt into a list and then you can subscript or stream over the list when you need to work with a particular data table.

open tables = List();

For( i = 1, i <= 10, i++,
	Original_table << select where( :Sorting Condition == i );
	dti = Original_table << Subset(
		Output table( "cond" || Char( i ) ),
		Selected Rows( 1 ),
		Selected columns only( 0 )
	);
	Insert Into( open tables, dti );
);

open tables[i] << New Column( "random",
	numeric,
	continuous,
	formula( Round( Random Uniform( 1, 150 ) ), 0 )
);
jgrosjean
Level I

Re: Reference Subset Data Tables Created from a Loop

That works great! Thanks!

Recommended Articles