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
DrMoka
Level I

Generating a Recode Column script...

I am running multiple analyses for different tables. Each table has a column for diagnosis and there are over 900 different types of diagnosis. SO what I do is recode column and then reclassify each diagnosis into 40 "diagnostic classes". However this is a tedious process repeating the recoding of the diagnoses column for each table.

 

Need help creating a recode script that captures the logic for grouping 900 diagnosis into 40 clusters and then apply the same recode process to a similar column in different tables. Is there a way to save and apply the recode script to a new column?

2 REPLIES 2
gzmorgan0
Super User (Alumni)

Re: Generating a Recode Column script...

It is not clear from your post whether you are creating the 40 classifications from a clustering analysis, or whether you are doing it manually by the diagnosos name and using Recode.

 

Also, you did not mention which version of JMP you are using. If you have recoded one table's 900 to 40 categories, depending upon your version of JMP you might have the option for Script > Save to File. Below is a screenshot of the option using JMP PRO v 14.2. The save script is attached.  You could run this script after opening each file and the recode column (in my script it is called orginal 2) will be created automatically.   However, I am not sure of the performance if you have extremely large files. (More discussion below).

 

image.png

What does seem to work very quickly is an associative array which is a keyed list.

 

Attached are 2 tables,

  • firsttbl_recodebyhand.jmp
  • newtbl.jmp

Open firtstbl_recodebyhand.jmp. It needs to have the original column and the recoded column, then run this script, changing the names to match your hand recoded table columns, and run this script

 

dt = current data table();
ng_aa = Associative Array(:original, :original2);
aa_str = "ng_aa =" || Log Capture(write(ng_aa)) ||";";
save text file("c:\temp\myrecode.txt", aa_str);

Next open newtbl.jmp. Note there are more rows and it is in random order. Now run this script

names default to here(1);
dt = current data table();  //open newtbl
_cmd_str = LoadTextFile("c:\temp\myrecode.txt");
Eval(Parse(_cmd_str));
dt << new Column("original 2", character, <<set each value(ng_aa[:original]) );

The associative array acts as a look-up function.  An assocaitive array is likely available on all versions of JMP.

 

This discussion so far assumes you have a hand recoded column.  If you have used other methods like a k-means cluster analysis or other algorithmic methods, JMP likely has a Save Formula option and you could just copy and paste that formula each time you open a new file.

 

Without more details, I have nothing more to offer.  

DrMoka
Level I

Re: Generating a Recode Column script...

Thank YOU...

 

I am using JMP V14.2. 

 

I was able to save the script of the recoded column. Will try to run the script with another table and see if that works. 

Thanks

DrMoka