How to group multiple data transformations into one script
Jul 10, 2019 8:56 AM(572 views)
I'm kind of new to scripting, and I was wondering if anyone can help me with finding resources to learn about how to put this process into one script. Here is an outline of the work that I have done.
1. Use tabulate to create summaries from an original table
2. Save tabulate as data table (the result is 3 separate tables)
3. For each of the 3 tables
a. Add a new column with a formula
b. Create new data table by stacking new column with two other existing columns
c. Rename two columns in new stacked data table
d. Create graph builder on stacked table
e. Save graph builder as interactive HTML
I'm pretty familiar with how to save scripts for the graph builder, and saving to the interactive HTML, but I get into trouble with saving the scripts from the data manipulation steps, as well as adding the new formula column, and the column renaming. My vision is to put this whole process into one script that will run on the original table, and create the 3 interactive HTMLs as a result. Any help is appreciated, or direction to resources.
Jeff, you are talking like you are ready to go the next level with understanding how to use JSL. I encourage to read the JMP Books on scripting, those will help you on your path.
For your problem, i've created a shell of what your script could look like.
// create a reference to the current data table
dt=current data table();
// do your summaries
dt1= (dt << Tabulate(...)) << make into data table;
dt2= (dt << Tabulate(...)) << make into data table;
dt3= (dt << Tabulate(...)) << make into data table;
// add column to each new data table
dt1 << New Column("column name", Formula(...));
dt2 << New Column("column name", Formula(...));
dt3 << New Column("column name", Formula(...));
// stack each table
dt1stack=dt1 << Stack(...);
dt2stack=dt2 << Stack(...);
// create graphs
g1=dt1stack << Graph Builder(...);
g2=dt2stack << Graph Builder(...);
g3=dt3stack << Graph Builder(...);
// save as interactive HMTL
g1 << Save Interactive HTML(<pathname1>);
g2 << Save Interactive HTML(<pathname2>);
g2 << Save Interactive HTML(<pathname3>);
The "..."'s in the script is for you to figure out, but those are easy to obtain by doing the action manually first and look at the resulting script that is either created in the data table (look for the "Source" script in the data table) or by saving the script from the analysis platform report. The last step "Save Interactive HTML", well you just have to look that up. I used the Scripting Index (Help > Scripting Index) and search on "Interactive', and it gave some example code that I see how to do it.