I routinely perform the same data table manipulation and calculations and am interested in automating that with a script.
The general steps are something like:
- Split table (split column "value" by column "attribute") > generates a new table
- Generate a new column (C) = column A + column B
- Generate new column (D) = column A / column C
However, every table has a different number of rows and different values. When I click through these functions and examine the script generated by JMP, the number of rows and values in each column are hard-coded. How do I make these completely variable so I can run the script on new data tables of any size?
So far, I have a script that looks like this, but it prompts you for the number of rows, then just generates an empty table. I'm having a hard time finding documentation, so any help is appreciated!
New Table( "split table",
Add Rows(),
New Script(
"Source",
Data Table() <<
Split(
Split By( :attribute ),
Split( :value ),
Output Table( "split table" ),
Sort by Column Property ) ),
New Column( "date", Character( 1 ), "Nominal", Set Values( {""} ) ),
New Column( "A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( {""} ) ),
New Column( "B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( {""} ) ),
New Column( "C", Numeric, "Continuous", Format( "Best", 12 ), Formula( :Name( "A" ) + :Name( "B" ) ) ),
New Column( "D", Numeric, "Continuous", Format( "Percent", 12, 0 ), Formula( :Name( "A" ) / :Name( "C" ) ) ) )