cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
lgober
Level II

Setting Row Values Under a Given Condition

Hello,

 

I am new to JSL and attempting to create a script that will change the value of certain rows in a given column.

 

The general issue I am having is that my data is being categorized as from different locations, when in fact those sites are the same. So when I go to graph them, I get more groups than necessary.

 

Here is the snippet of code that I was hoping would accomplish my goal:

 

for each row(
	if( As Column( dtSum:Name( "Originating Fab" )) == "D1C",
		As Column( dtSum:Name( "Originating Fab" )) << Set Values( { "D1D" } );
	);
);

Where 'dtSum' is my summary table and 'Originating Fab' is the column that depicts what location that row is from.

 

So in the above code, I want to change the Originating Site values from "D1C" to "D1D", since those are both the same location.  

 

Any help would be greatly appreciated.

 

Thanks,

 

Lain

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Setting Row Values Under a Given Condition

Right click on the column of interest and select Recode.  You will be able to select existing values in your column and specify what to change them to.  This is the interactive method that I was talking about.

Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Setting Row Values Under a Given Condition

You may want to explore doing this interactively, and using Recode to make these changes.  It can also generate a script to make the changes.

 

But if you really need to do this in JSL, I more efficient way of doing this is to use Get Rows Where() and doing the change all at once, without having to loop

dtSum:Name( "Originating Fab" )[ dtSum<<get rows where( dtSum:Name( "Originating Fab" )  == "D1C")] = "D1D";

 Also, if you want to continue using the looping format, this is a more concise version of your code

for each row(
	if( dtSum:Name( "Originating Fab" ) == "D1C",
		dtSum:Name( "Originating Fab" ) ="D1D";
	);
);
Jim
lgober
Level II

Re: Setting Row Values Under a Given Condition

Hey Jim,

Thanks for the quick reply, I had not heard of the get Rows Where() function before.

However neither of those solutions seem to do me any good.

I knew that JMP could generate scripts interactively, but I am not familiar enough with how to do that in this context. (I've mostly used that for graphs.)

Any help with the interactive route?

txnelson
Super User

Re: Setting Row Values Under a Given Condition

Right click on the column of interest and select Recode.  You will be able to select existing values in your column and specify what to change them to.  This is the interactive method that I was talking about.

Jim