cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Neo
Neo
Level VI

Loop through cols/rows of two separate tables for getting arguments into a function

I have got a working function which plots trends and distribution for measured parameters (columns in a table1) using test limits (LSL, USL in another table, table2).

 

Names Default To Here (1);

getTrendChartAndDist = Function({colName, LSL, USL}, {TrendDistChart},

New Window(""||colName||" Trend & Distribution",

Graph Builder(
	something here .....
);

return(TrendDistChart);
);

In order to plot the charts for all measured parameters, now need to loop through each column of a data table to go into "colName" (say col 3 to col 9 for the measured parameters in table1) and simultaneously get the limits (LSL and USL) for each colName from another table, table2 (table2 has each measured parameter in rows, with LSL and USL in separate columns). I am messing up the simultaneous looping. How to go about this? Any help is appreciated. 

When it's too good to be true, it's neither
1 REPLY 1

Re: Loop through cols/rows of two separate tables for getting arguments into a function

Is something like this what you're looking for?

/*JMP STATISTICAL DISCOVERY LLC (“JMP”) PERMITS THE USE OF THIS COMPUTER SOFTWARE CODE (“CODE”) ON AN AS-IS BASIS AND AUTHORIZES YOU TO USE THE CODE SUBJECT TO THE TERMS LISTED HEREIN.  BY USING THE CODE, YOU AGREE TO THESE TERMS.  YOUR USE OF THE CODE IS AT YOUR OWN RISK.  JMP MAKES NO REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRIGEMENT, AND TITLE, WITH RESPECT TO THE CODE.
You may use the Code solely as part of a software product you currently have licensed from JMP, JMP’s parent company SAS Institute Inc. (“SAS”), or one of JMP’s or SAS’s subsidiaries or authorized agents (the “Software”), and not for any other purpose.  The Code is designed to add functionality to the Software but has not necessarily been tested.  Accordingly, JMP makes no representation or warranty that the Code will operate error-free.  JMP is under no obligation to maintain, support, or continue to distribute the Code.
Neither JMP nor its licensors shall be liable to you or any third-party for any general, special, direct, indirect, consequential, incidental, or other damages whatsoever arising out of or related to your use or inability to use the Code, even if JMP has been advised of the possibility of such damages.  Except as otherwise provided above, the Code is governed by the same agreement that governs the Software.  If you do not have an existing agreement with JMP or SAS governing the Software, you may not use the Code.
JMP and all other JMP Statistical Discovery LLC product or service names are registered trademarks or trademarks of JMP Statistical Discovery LLC in the USA and other countries.  ® indicates USA registration.  Other brand and product names are registered trademarks or trademarks of their respective companies.
*/

Names Default To Here (1);
//make data tables
dt1 = New Table( "dt1",
	Add Rows( 1 ),
	New Column( "A",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1] )
	),
	New Column( "B",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1] )
	),
	New Column( "C",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1] )
	)
);
dt2 = New Table( "dt2",
	Add Rows( 3 ),
	New Column( "X",
		Character,
		"Nominal",
		Set Values( {"A", "B", "C"} ),
		Set Display Width( 56 )
	),
	New Column( "Y",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [5, 5, 5] )
	)
);

current data table(dt1); //the Column Name function used below relies on current data table
//cycle through tables
for each ({i}, 1::3, // <--change to 3::9 
	n = char(Column Name(i));
	dt2 << Select where (:X == n);
	r = (dt2 << Get Selected Rows())[1]; //find row number in dt2
	val = dt2:Y[r]; //get value from dt2
	wait (.25);	//<--replace with your code
);