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
GardDog
Level III

How can I use a jmp script to select specific rows and delete specific rows using multiple arguments?

I have tried looking this up in the help guide, and it looks like I am applying it correctly, but it does not seem to be working. Could someone please check if I am missing something?

I have a column that I created from another column and rounded the values. I need to keep only a range of the rows based off of values in the new column. I want to keep only New Y values that are between 50000, and 50999 and delete the rest of the rows. 

Here is the part of my script that has this command, but it is not working. You can see the commented out line prior to the current one I am working on this was working, but now there could be other values in the range of 50000's that I need to keep. 

I also attached my whole script if needed as a reference.

 

dt = Current Data Table();

Column( dt, "X coordinate" ) << data type( Numeric ) << Modeling Type( Continuous ) << Format( Best, 12 );

dt << New Column( "New Y", Numeric, Nominal, Width( 5 ), Formula( Round( Y coordinate ) ) );

//dt << select where( :New Y != 50503 );
dt << select where( :New Y < 50000 & :New Y > 50999 );
dt << delete rows;
dt << New Column( "Normalized", Numeric, Continuous, Width( 10 ), Precision( 7 ), Formula( IntenCD / Col Max( IntenCD ) ) );

 

Thanks in advance for any help with this.

Clear Symbols();
Names Default To Here( 1 );

framex_value = "";
lotid_value = "";
w = New Window( "Requested Information", // opens a window with a title and this content...
	<<Return Result,
	Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), // window dressing 
		V List Box( // V and H lists nest to organize the display boxes
			H Center Box( Text Box( "Requested Information..." ) ), // a second title, centered
			Spacer Box( size( 1, 20 ) ), // a little vertical space
		    H List Box( Text Box( "             Lot#: " ), lotid = Number Edit Box( ) ), // data entry
			Spacer Box( size( 1, 10 ) ), // a little vertical space
			H List Box( Text Box( "Frame size X: " ), framex = Number Edit Box( ) ), // data entry	
			Spacer Box( size( 1, 10 ) ), // a little vertical space
			H Center Box( // center the button
				Button Box( "Create graph", // this script runs when the button is pressed...
					lotid_value = lotid << get;
					framex_value = framex << get;
					
					dt = Current Data Table();
					
					Column( dt, "X coordinate" ) << data type( Numeric ) << Modeling Type( Continuous ) << Format( Best, 12 );
					
					dt << New Column( "New Y", Numeric, Nominal, Width( 5 ), Formula( Round( Y coordinate ) ) );
					
					//dt << select where( :New Y != 50503 );
					dt << select where( :New Y < 50000 & :New Y > 50999 );
					dt << delete rows;
					dt << New Column( "Normalized", Numeric, Continuous, Width( 10 ), Precision( 7 ), Formula( IntenCD / Col Max( IntenCD ) ) );
					
					// Determine Matrix
					xMat = Matrix( 76200 - (framex_value / 2) ) |/ Matrix( 76200 - (framex_value / 2) ) |/ Matrix( 76200 + (framex_value / 2) ) |/
					Matrix( 76200 + (framex_value / 2) );
					// The yMat is static
					yMat = [1, 0.92, 0.92, 1];
					
					// The overall delta
					overallDelta = Col Max( dt:Normalized ) - Col Min( dt:Normalized );
									
					//The delta between the lines
					withinOrangeDelta = Col Max(
						If( dt:X coordinate > (76200 - (framex_value / 2)) & dt:X coordinate < (76200 + (framex_value / 2)),
							dt:Normalized,
							.
						)
					) - Col Max( dt:Normalized ) - Col Min( dt:Normalized ) + 1;
					Col Min( If( dt:X coordinate > (76200 - (framex_value / 2)) & dt:X coordinate < (76200 + (framex_value / 2)), dt:Normalized, . ) );
					
								// Graph Builer and Delta display
					gb = dt << Graph Builder(
						Size( 534, 456 ),
						Show Control Panel( 0 ),
						Variables( X( dt:X Coordinate ), Y( dt:Normalized ) ),
						Elements( Points( X, Y, Legend( 5 ) ) )
					);
					
					Report( gb )[FrameBox( 1 )] << Add Graphics Script(
						Pen Color( "orange" );
						Pen Size( 2 );
						Line( xmat, ymat );
													
													// Add the results to the chart
						Text( Boxed, {75000, .94}, "Overall Delta = " || Char( Format( overallDelta, 7, 4 ) ) );
						Text( Boxed, {75000, .93}, "Within Frame Delta = " || Char( Format( withinOrangeDelta, 7, 4 ) ) );
					);
					Report( gb )[AxisBox( 2 )] << Min( .91 );
					
					Report( gb )<<save picture( "\\bofs23b\aera_data\Pellicle_Transmission/" || Char( lotid_value ) ||".jpg", "jpg" );
					
					//allTransmissions = Format( overallDelta, 7, 4, withinOrangeDelta, 7, 4);
					//A = [1 2 3]; B = [4 5 6]; Concat To( A, B ); Show( A );
					A = Char( Format( overallDelta, 7, 4 ) );
					B = ",";
					C = " ";
					D = Char( Format( withinOrangeDelta, 7, 4 ) );
					Concat To(A, B, C, D);
					Save Text File( "\\bofs23b\aera_data\Pellicle_Transmission\" || Char( lotid_value ) ||".txt", A);

										
					w << closeWindow;

				)
			)
		)
	)
  
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How can I use a jmp script to select specific rows and delete specific rows using multiple arguments?

Here is the Select Where() clause you want to use

dt << select where( :New Y <= 50000 | :New Y >= 50999 );
Jim

View solution in original post

7 REPLIES 7
Jeff_Perkinson
Community Manager Community Manager

Re: How can I use a jmp script to select specific rows and delete specific rows using multiple arguments?

I think it's just a logic problem.

 

Your select where statement:

 

dt << select where( :New Y < 50000 & :New Y > 50999 );

can never be true since :New Y can't be less than 50000 and greater than 50999 at the same time.

 

Instead, you want:

 

dt << select where( 50000 <= :New Y <= 50999 );

 

-Jeff
GardDog
Level III

Re: How can I use a jmp script to select specific rows and delete specific rows using multiple arguments?

Oh man, thanks. That does make sense. I replaced my code with that new line, but it still does not actually delete all the other rows that need deleted, so that I am only graphing the New Y values between 50000 and 50999. What else could I be missing?

txnelson
Super User

Re: How can I use a jmp script to select specific rows and delete specific rows using multiple arguments?

It is tough to debug without sample data.....could you possibly provide a sample table
Jim
GardDog
Level III

Re: How can I use a jmp script to select specific rows and delete specific rows using multiple arguments?

Yes, here is one of my data sets, thanks for the help!

GardDog
Level III

Re: How can I use a jmp script to select specific rows and delete specific rows using multiple arguments?

Hi, I still cannot figure out how to get all but a specific range of Y coordinates to be deleted. With the update from previous help this is my new script for the section I am working on. So I need to keep only Y values from 50000 to 50999, and delete the rest.

 

dt = Current Data Table();

Column( dt, "X coordinate" ) << data type( Numeric ) << Modeling Type( Continuous ) << Format( Best, 12 );

dt << New Column( "New Y", Numeric, Continuous, Width( 10 ), Formula( Round( Y coordinate, 0 ) ) );

//dt << select where( :New Y != 50503 );
dt << select where( 50000 <= :New Y <= 50999 );
dt << delete rows;
dt << New Column( "Normalized",
    Numeric,
    Continuous,
    Width( 10 ),
    Precision( 7 ),
    Formula( IntenCD / Col Max( IntenCD ) )
);
txnelson
Super User

Re: How can I use a jmp script to select specific rows and delete specific rows using multiple arguments?

Here is the Select Where() clause you want to use

dt << select where( :New Y <= 50000 | :New Y >= 50999 );
Jim
GardDog
Level III

Re: How can I use a jmp script to select specific rows and delete specific rows using multiple arguments?

Perfect, that did the trick. Thanks for the help!