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
Jackie_
Level VI

Offset Site 1 data

Hi,

I have a jmp script that offsets the test results based upon the reference data table values.

It will:

1. Read data table and reference data table

2. Generate a new window to select site number, 

3. Based on the user input (Site Number 1 or 2), align those data to the reference data table values

 Take mean by wafer Id, apply the offset to the main data table

Here's the script: It doesn't produces expected output

Names Default To Here( 1 );
dt1 = Data Table( "Reference data table" );
dt2 = Current Data Table();

For( i = 1, i <= N Rows( dt1 ), i++,
	theTest = dt1:Tests[i];
	Try( Column( dt2, theTest ) << set property( "TheMean", dt1:mean[i] ) );
);
		New window( "", modal,
			ct = checkbox({"1","2"}),
			Buttonbox ("Ok",
				get = ct << Get Selected ();
			)
	
	
);
sitenum = Transform Each({str}, get, Num(str));	
Col_List1 = dt2 << Get Column Names( "String" );
For( c = 1, c <= N Col( dt2 ) - 1, c++,
	theMatrix = [];
	name = Column( Col_List1[c] ) << Get name;
	If( Contains( Col_List1[c], "IL" ), 
	
		mean = .;
		Try( mean = Column( dt2, col_list1[c] ) << get property( "theMean" ) );
		// Don't process if a value for theMean does not exist
		If( Is Missing( mean ) == 0,
			For Each Row(
			If( Contains(sitenum, dt2:SiteNumber), // Something needs to be changed here *****
				r = Row();
		//mean = dt1:Mean[dt1 << Get Rows Where( :Tests == name )];
		
				//measure = mean - Col Mean( If( dt2:Strips == dt2:Strips[r], Column( dt2, c ), . ) );
				measure = mean - Col Mean( As Column( dt2, c ), :Wafer ID );
				theMatrix = theMatrix || Column( dt2, c )[r] + measure;
			);
			);
			Column( dt2, c ) << Set Values( theMatrix );
		);
	);
);
7 REPLIES 7
David_Burnham
Super User (Alumni)

Re: Offset Site 1 data

The way I would handle this would be to put show statements in the code to determine at what point I am failing to get correct results.  For example, after transform each, put show(sitenum).  This way you can trace through the progression of the logic and see where it fails.  Alternatively you can use the debugger tool to perform the same task.

-Dave
Jackie_
Level VI

Re: Offset Site 1 data

@txnelson appreciate if you can advice

txnelson
Super User

Re: Offset Site 1 data

Names Default To Here( 1 );
dt1 = Data Table( "Reference data table" );
dt2 = Current Data Table();

For( i = 1, i <= N Rows( dt1 ), i++,
	theTest = dt1:Tests[i];
	Try( Column( dt2, theTest ) << set property( "TheMean", dt1:mean[i] ) );
);
New Window( "",
	modal,
	ct = Check Box( {"1", "2"} ),
	Button Box( "Ok", get = ct << Get Selected() )
	
	
);


sitenum = Transform Each( {str}, get, Num( str ) );
Col_List1 = dt2 << Get Column Names( "String" );
For( c = 1, c <= N Col( dt2 ) - 1, c++,
	theMatrix = [];
	name = Column( Col_List1[c] ) << Get name;
	
	// The following code is never executed since none of the column names
	// have the value "IL" in their name
	If( Contains( Col_List1[c], "IL" ), 
		mean = .;
		Try( mean = Column( dt2, col_list1[c] ) << get property( "theMean" ) );
		// Don't process if a value for theMean does not exist
		If( Is Missing( mean ) == 0,
			For Each Row(
				If( Contains( sitenum, dt2:SiteNumber ), // Something needs to be changed here *****
					r = Row();
		//mean = dt1:Mean[dt1 << Get Rows Where( :Tests == name )];
		
					//measure = mean - Col Mean( If( dt2:Strips == dt2:Strips[r], Column( dt2, c ), . ) );
					measure = mean - Col Mean( As Column( dt2, c ), :Wafer ID );
					theMatrix = theMatrix || Column( dt2, c )[r] + measure;
				)
			);
			Column( dt2, c ) << Set Values( theMatrix );
		);
	);
	
);
Jim
Jackie_
Level VI

Re: Offset Site 1 data

@txnelson Sorry. There was a typo in the code.

 

Here's the correct statement:

// The following code is never executed since none of the column names
	// have the value "IL" in their name
	If( Contains( Col_List1[c], "Current" ), 
txnelson
Super User

Re: Offset Site 1 data

You need to either step through the code using the Show() function to see what values are being set to and then determine where your logic is going wrong, or use the JMP Debugger to do the analysis with.  

That is the method that I or anyone else on the forum would have to do.  And you have the advantage of understanding what you expect the output to be.

Jim

Re: Offset Site 1 data

You might also use the JMP Debugger to examine or watch variables using breakpoints or stepping through the code.

pauldeen
Level VI

Re: Offset Site 1 data

You should really learn how to ask better questions...and learn how to debug scripts. Having said that, here is a working script that does what you need:

Names Default To Here( 1 );
dt1 = Data Table( "Reference data table" );
dt2 = Current Data Table();

For( i = 1, i <= N Rows( dt1 ), i++,
	theTest = dt1:Tests[i];
	Try( Column( dt2, theTest ) << set property( "TheMean", dt1:mean[i] ) );
);

New Window( "",
	modal,
	ct = Check Box( {"1", "2"} ),
	Button Box( "Ok", get = ct << Get Selected() )
	
	
);

sitenum = Transform Each( {str}, get, Num( str ) );
Col_List1 = dt2 << Get Column Names( "String" );
For( c = 1, c <= N Col( dt2 ) - 1, c++,
	If( Contains( Col_List1[c], "Current" ),
		mean = .;
		Try( mean = Column( dt2, col_list1[c] ) << get property( "theMean" ) );
		// Don't process if a value for theMean does not exist
		If( !Is Missing( mean ),
			For(k=1, k<= n items(sitenum), k++,
				rows = dt2 << Select Where( :SiteNumber == sitenum[k] ) << Get Selected Rows;
				dt2 << Clear Select();
				NewValues = Column( dt2, c )[rows]+mean;
				For(i=1, i<= n items(NewValues), i++,
					Column( dt2, c )[rows[i]] = NewValues[i]
				);
			);
		);
	);
);