cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
olivier_brack
Level II

Recode a column using JSL

I would like to recode (by JSL) a column using the 'Split On' advanced option 'Split Delimiter'= (Text)...

9 REPLIES 9

Re: Recode a column using JSL

Did you perform the task manually to verify the results are what you want? If so, did you save the results in a new data column with a formula? If so, then examine the formula to see how it might be done in a script.

olivier_brack
Level II

Re: Recode a column using JSL

Hi, Mark

Yes but the result is a match formula

I would like, if possible, to script the recoding, using recode options

something like 

dt_:var_name << recode(split delimiter text("String"))....

I don't know if that's possible.

txnelson
Super User

Re: Recode a column using JSL

My suggestion is similar to @Mark_Bailey.  But rather than saving the column's formula, you can manually create the recode, but before actually completing the recode, you can go to the red triangle, and select

     Script==>Save to Script Window

and it will show you the script necessary to generate the recode you have specified

Current Data Table() << Begin Data Update;
dc1 = New Column( :weight );
dc1 << Set Name( "weight 2 2" );
Current Data Table() << Go to( dc1 );
Current Data Table() << Move Selected Columns( after( :weight ) );
For Each Row(
	dc1[] = Match( :weight,
		64, 60,
		67, 60,
		74, 70,
		79, 70,
		81, 80,
		84, 80,
		85, 80,
		91, 90,
		92, 90,
		93, 90,
		95, 90,
		98, 90,
		99, 90,
		104, 100,
		105, 100,
		106, 100,
		107, 100,
		111, 110,
		112, 110,
		113, 110,
		115, 110,
		116, 110,
		119, 110,
		123, 120,
		128, 120,
		134, 130,
		142, 140,
		145, 140,
		172, 170,
		:weight
	)
);
Current Data Table() << End Data Update;

 

Jim
olivier_brack
Level II

Re: Recode a column using JSL

Thank you but I'ld to avoid the match scripting because this recoding will be implemented within a global script and the text delimiter could be changed by my user depending on the column to be recoded.

That's why i'ld prefer, if possible, to write the recoding function using options...

Re: Recode a column using JSL

I think that you need to consider all the character functions in JSL to make a formula of your own and either save it as a new column (recoded values) or use the expression to compute the values row-wise without a script.

 

Your descriptions so far are too vague to permit anyone to offer more specific suggestions.

olivier_brack
Level II

Re: Recode a column using JSL

Thank you Mark

If I understand well, the recode function doesn't exist in JSL...

So, we're not able to script what we do manually using the red triangle options (Split on, advanced, ...) proposed when we recode a column.

I'll use the basic character functions...

 

Re: Recode a column using JSL

That is correct, Recode is a column action, not a JSL function. There is a data column message << Recode that opens the interactive recoding editor but there is nothing to automatically apply recoding rules. On the other hand, the collection of character string functions is rich and offers a lot of help.

 

Can you provide examples of the original values and the desired recoded results? That might allow us to make better suggestions, if you still want more help.

Re: Recode a column using JSL

Right, so you know it works. Now, copy that formula and paste it over the 'recode expression' in this script to accomplish the same thing.

 

Current Data Table() << New Column( "Recoded",
	Formula( recode expression )
);
olivier_brack
Level II

Re: Recode a column using JSL

Thank you all

This problem is solved...