Char
Char using New Window
Summary: Creates a matrix box with detailed row names and column headers from a data table, utilizing JMP's scripting capabilities.
Code:
dt = Open("data_table.jmp");
i = 1;
New Window( "",
Matrix Box(
dt << get as matrix,
<<Column Names( "age", "height", "weight" ),
<<Row Names( Repeat( {"r" || Char( i++ )}, N Row( dt ) ) )
)
);
Code Explanation:
- Open data table.
- Initialize counter variable.
- Create new window.
- Add matrix box.
- Convert data table to matrix.
- Set column names.
- Generate row names.
- Concatenate prefix with row index.
- Repeat for all rows.
- Assign row names.
Chart
Summary: Creates a bar chart to visualize mean age by marital status, country, and sex, with custom formatting for scale boxes.
Code:
dt = Open("data_table.jmp");
Chart(
Grouping( :marital status, :country ),
X( :sex ),
Y( Mean( :age ) ),
Bar Chart( 1 ),
SendToReport(
Dispatch( {}, "102", ScaleBox,
{Format( "Custom", Formula( Char( Round( In Years( value ) / 100000000, 1 ) ) || "e+8 (s)" ), 12 )}
)
)
);
Code Explanation:
- Open data table.
- Create chart object.
- Set grouping variables.
- Define X-axis variable.
- Define Y-axis variable.
- Create bar chart.
- Send report to chart.
- Dispatch to scale box.
- Format scale box.
- Apply custom formula.
Char using Format
Example 1
Summary: Formats height and weight values in a data table by appending custom units to each value.
Code:
Open("data_table.jmp");
:height << Format( "Custom", Formula( Char( value ) || "in" ), 12 );
:weight << Format( "Custom", Formula( Char( value ) || "lb" ), 12 );
Code Explanation:
- Open data table.
- Set custom format for height.
- Append "in" to height values.
- Set custom format for weight.
- Append "lb" to weight values.
Example 2
Summary: Runs the formatting and creation of a new table with specific column formats, utilizing JSL scripting language.
Code:
dt = Open("data_table.jmp");
:Date << Format( "ddMonyyyy", 10 );
:DJI High << Format( "Currency" );
:DJI Close << Format( "best", "Use Thousands Separator", 10, 0 );
:DJI Low << Format( "Fixed Dec", "Use Thousands Separator", 10, 2 );
colset = {};
For( i = 1, i <= N Col( dt ), i++,
Insert Into( colset, Char( Column( i ) << Get Format ) )
);
Close( dt, nosave );
dt = New Table( "AgreementTestTable2[1]",
Add Rows( 4 ),
New Column( "A", Numeric, Nominal, Format( "Best", 12 ), Set Values( [1000, 1000, 3000, 1000] ) ),
New Column( "B", Numeric, Nominal, Format( "Best", "Use thousands separator", 12 ), Set Values( [2000, 4000, 2000, 1000] ) ),
New Column( "C", Numeric, Nominal, Format( "Best", Use thousands separator( 1 ), 12 ), Set Values( [1000, 4000, 1000, 1000] ) ),
New Column( "Part 1", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1000, 1000, 1000, 1000] ) ),
New Column( "Part 2", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1000, 1000, 1000, 1000] ) ),
New Column( "Part 3", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1000, 1000, 1000, 1000] ) )
);
Column( "Part 1" ) << Format( "Use thousands separator" );
Column( "Part 2" ) << Format( Use thousands separator( 1 ) );
Column( "Part 3" ) << Format( Use Thousands separator );
colset = {};
For( i = 1, i <= N Col( dt ), i++,
Insert Into( colset, Char( Column( i ) << Get Format ) )
);
Code Explanation:
- Open data table.
- Format Date column.
- Format DJI High column.
- Format DJI Close column.
- Format DJI Low column.
- Initialize column set.
- Loop through columns.
- Insert column formats into set.
- Close table without saving.
- Create new table.
- Add rows to new table.
- Add columns with specific formats.
- Set values for columns.
- Format Part 1 column.
- Format Part 2 column.
- Format Part 3 column.
- Reinitialize column set.
- Loop through columns again.
- Insert new column formats into set.
Example 3
Summary: Formats a table by setting date, currency, and number formats for specific columns.
Code:
dt = Open("data_table.jmp");
:Date << Format( "ddMonyyyy", 10 );
:DJI High << Format( "Currency" );
:DJI Close << Format( "best", "Use Thousands Separator", 10, 0 );
:DJI Low << Format( "Fixed Dec", "Use Thousands Separator", 10, 2 );
colset = {};
For( i = 1, i <= N Col( dt ), i++,
Insert Into( colset, Char( Column( i ) << Get Format ) )
);
Code Explanation:
- Open table.
- Format Date column.
- Format DJI High column.
- Format DJI Close column.
- Format DJI Low column.
- Initialize column set.
- Loop through columns.
- Get format for each column.
- Convert format to character.
- Insert format into column set.
Char using New Column
Example 1
Summary: Creates a new character column 'ID Col' in a JMP data table, concatenating survey, choice set, and choice ID variables.
Code:
dt = Open( "data_table.jmp", invisible );
dt << New Column( "ID Col",
Character( 6 ),
"Nominal",
Formula( Char( :Survey ) || "_" || Char( :Choice Set ) || "_" || Char( :Choice ID ) )
);
dt:ID Col << Set Property( "Link ID", 1 );
Code Explanation:
- Open data table.
- Create new column "ID Col".
- Set column data type to character.
- Define column as nominal.
- Assign formula to concatenate survey, choice set, and choice ID.
- Set property "Link ID" to 1.
Example 2
Summary: Creates a new numeric column with continuous values, formatted as date-time and set to 100, in a JMP data table.
Code:
dt = Open("data_table.jmp");
dt << New Column( "example", Numeric, Continuous, Width( 5 ), Format( ddMonyyyy h:m:s ), <<Set Each Value( 100 ) );
fmt = {};
fmt = Char( :example << get format );
Code Explanation:
- Open data table;
- Create new column "example".
- Set column type to numeric.
- Define column as continuous.
- Set column width to 5.
- Apply date-time format.
- Set each cell value to 100.
- Initialize empty list fmt.
- Retrieve format of "example" column.
- Convert format to character.
Example 3
Summary: Runs data table manipulation by reversing row order, reordering columns by modeling type and data type, and restoring original order.
Code:
dt = Open("data_table.jmp");
dt << New Column( "RowState", Rowstate );
n = Char( dt << Get Column Names() );
dt << Reverse Order;
n = Char( dt << Get Column Names() );
dt << Reorder By Modeling Type;
n = Char( dt << Get Column Names() );
dt << Reorder By Data Type;
n = Char( dt << Get Column Names() );
dt << Reorder By Name;
n = Char( dt << Get Column Names() );
dt << Original Order;
n = Char( dt << Get Column Names() );
Code Explanation:
- Open data table;
- Add RowState column.
- Store initial column names.
- Reverse order of rows.
- Store reversed column names.
- Reorder by modeling type.
- Store reordered column names.
- Reorder by data type.
- Store reordered column names.
- Reorder by name.
- Store final column names.
- Restore original order.
Example 4
Summary: Runs data manipulation and string processing tasks, including creating new columns, extracting values, and modifying strings.
Code:
dt = Open("data_table.jmp");
dt << New Column( "Soccer", numeric, continuous, Formula( Contains Item( dt:sports, "Soccer", ", " ) ) );
dt << New Column( "Stomach", numeric, continuous, Formula( Contains Item( Lowercase( dt:reported illnesses ), "stomach", ", " ) ) );
cars = dt:family cars << get values;
dt << New Column( "Cars MR Prop", character, nominal, Set Property( "Multiple Response", {Separator( "," )} ), Set Values( cars ) );
dt << New Column( "Jetta", numeric, continuous, Formula( Contains Item( dt:Cars MR Prop, "Jetta", ", " ) ) );
Close( dt, "nosave" );
ut_s = "Plan A";
Substitute Into( ut_s, "A", "B" );
ut_s = "live on";
Reverse Into( ut_s );
Insert Into( ut_s, "u", 3 );
ut_s = "abcdefghijklmnopqrstuvwxyz";
utrad = Substr( Char( 1.5 ), 2, 1 );
Code Explanation:
- Open data table.
- Create "Soccer" column.
- Create "Stomach" column.
- Extract family car values.
- Create "Cars MR Prop" column.
- Create "Jetta" column.
- Close table without saving.
- Initialize string variable.
- Substitute "A" with "B".
- Modify string to reverse.
Example 5
Summary: Creates new columns in a JMP data table, calculating mean, standard deviation, sum, minimum, and maximum values for specific conditions.
Code:
dt = Open("data_table.jmp");
dt << New Column( "Col1", Numeric, Formula( If( :sex == "M" & :age < 14, :height, Empty() ) ) );
dt << New Column( "Col2", Numeric, Formula( Col Mean( :Col1, Char( age ) ) ) );
dt << New Column( "Col3", Numeric, Formula( Col Mean( If( :sex == "M" & :age < 14, :height, Empty() ), Char( age ) ) ) );
dt << New Column( "Col4", Numeric, Formula( Col Std Dev( If( :sex == "M" & :age < 14, :height, Empty() ), Char( age ) ) ) );
dt << New Column( "Col5", Numeric, Formula( Col Sum( If( :sex == "M" & :age < 14, :height, Empty() ), Char( age ) ) ) );
dt << New Column( "Col6", Numeric, Formula( Col Min( If( :sex == "M" & :age < 14, :height, Empty() ), Char( age ) ) ) );
dt << New Column( "Col7", Numeric, Formula( Col Max( If( :sex == "M" & :age < 14, :height, Empty() ), Char( age ) ) ) );
Code Explanation:
- Open data table.
- Create new column "Col1".
- Define formula for "Col1".
- Create new column "Col2".
- Define formula for "Col2".
- Create new column "Col3".
- Define formula for "Col3".
- Create new column "Col4".
- Define formula for "Col4".
- Create new column "Col5".
- Define formula for "Col5".
- Create new column "Col6".
- Define formula for "Col6".
- Create new column "Col7".
- Define formula for "Col7".
Char using Delete Rows
Example 1
Summary: Modifies a data table by deleting rows, setting range and list checks, and converting columns to matrices.
Code:
dt = Open("data_table.jmp");
dt << Delete Rows( 21 :: 40 );
dt:height << Range Check( LE LT( 60, 65 ) );
dt:age << List Check( {12, 13} );
charrange = Char( dt:height << Get Property( "Range Check" ) );
charlist = Char( dt:age << Get Property( "List Check" ) );
mtx height = Char( dt << Get As Matrix( {height} ) );
mtx age = Char( dt << Get As Matrix( {age} ) );
dt:height << Range Check( LELE( 60, 63 ) );
dt:age << List Check();
Try( listch = dt:age << Get Property( "List Check" ) );
charlist = Char( listch );
Code Explanation:
- Open data table.
- Delete rows 21-40.
- Set height range check.
- Set age list check.
- Get height range check property.
- Get age list check property.
- Convert height to matrix.
- Convert age to matrix.
- Update height range check.
- Clear age list check.
Example 2
Summary: Runs data table manipulation by deleting rows, applying range and list checks, and converting data to matrices.
Code:
dt = Open("data_table.jmp");
dt << Delete Rows( 21 :: 40 );
dt:height << Range Check( LE LT( 60, 65 ) );
dt:age << List Check( {12, 13} );
charrange = Char( dt:height << Get Property( "Range Check" ) );
charlist = Char( dt:age << Get Property( "List Check" ) );
mtx height = Char( dt << Get As Matrix( {height} ) );
mtx age = Char( dt << Get As Matrix( {age} ) );
dt:height << Range Check();
Try( range = dt:height << Get Property( "Range Check" ) );
charrange = Char( range );
dt:age << List Check();
Try( listch = dt:age << Get Property( "List Check" ) );
charlist = Char( listch );
Code Explanation:
- Open data table;
- Delete rows 21 to 40.
- Apply height range check.
- Apply age list check.
- Get height range check property.
- Get age list check property.
- Convert height data to matrix.
- Convert age data to matrix.
- Remove height range check.
- Attempt to get updated height range check.
Example 1
Summary: Runs the processing and hiding of columns in a JMP data table, adding new numeric columns and retrieving column names.
Code:
dt = Open("data_table.jmp");
:x << hide( 1 );
:y << hide( 1 );
:State << hide( 1 );
:Region << hide( 1 );
:POP << hide( 1 );
dt << add multiple columns( "new", 3, after last, numeric );
colnames = Char( dt << Get Column Names() );
Close( dt, No Save );
certnames = "{A, A_, _A, _A_, A_B, A_B_}";
Code Explanation:
- Open data table;
- Hide column :x.
- Hide column :y.
- Hide column :State.
- Hide column :Region.
- Hide column :POP.
- Add 3 new numeric columns.
- Get column names.
- Close table without saving.
- Define certification names.
Example 2
Summary: Prepares a data table by hiding columns, adding new numeric columns, and retrieving column names.
Code:
dt = Open("data_table.jmp");
:x << hide( 1 );
:y << hide( 1 );
:State << hide( 1 );
:Region << hide( 1 );
:POP << hide( 1 );
dt << add multiple columns( "new", 3, after last, numeric );
colnames = Char( dt << Get Column Names() );
Code Explanation:
- Open data table;
- Hide X column.
- Hide Y column.
- Hide State column.
- Hide Region column.
- Hide POP column.
- Add 3 new columns.
- Get all column names.
Example 3
Summary: Runs data table operations by opening a file, retrieving scripts, converting column scripts to strings, evaluating the script, and retrieving the resulting script.
Code:
dt1 = Open("data_table.jmp");
s = dt1 << Get Script;
col1 = Char( dt1:Failure3 << Get Script );
dt2 = Eval( s );
col2 = Char( dt2:Failure3 << Get Script );
Code Explanation:
- Open data table.
- Retrieve script from data table.
- Convert Failure3 column script to string.
- Evaluate script to create new data table.
- Retrieve script from new data table's Failure3 column.
- Convert retrieved script to string.
Char using Row
Example 1
Summary: Opens and configures a JMP data table, setting row numbers and column properties.
Code:
dt = Open("data_table.jmp");
Row() = 1;
:name = "1";
Row() = 2;
:name = "1";
col = Column( "name" );
col << data type( numeric );
datatype = col << get data type;
actual = Char( col << get as matrix() );
Close( dt, No Save );
certempty = "Empty()";
Code Explanation:
- Open data table.
- Set row to 1.
- Assign value "1" to column.
- Set row to 2.
- Assign value "1" to column.
- Get column object.
- Change data type to numeric.
- Retrieve data type.
- Convert data to character matrix.
- Close table without saving.
Example 2
Summary: Process of setting row index, assigning values to a column, and retrieving its data type in JMP.
Code:
dt = Open("data_table.jmp");
Row() = 1;
:name = "1";
Row() = 2;
:name = "1";
col = Column( "name" );
col << data type( numeric );
datatype = col << get data type;
actual = Char( col << get as matrix() );
Code Explanation:
- Open data table;
- Set row index to 1.
- Assign "1" to column :name.
- Set row index to 2.
- Assign "1" to column :name.
- Retrieve column "name".
- Change column data type to numeric.
- Get column data type.
- Convert column data to matrix.
- Convert matrix to character string.
Char using Color by Column
Summary: Runs data visualization and customization for a JMP data table, applying colors and markers to marital status, country, row state, age, and size variables.
Code:
dt = Open("data_table.jmp");
dt << Color by Column( marital status, Color( 1 ), Color Theme( "JMP Light" ), );
dt << Marker by Column( country, Marker( 1 ), Marker Theme( "Classic" ) );
dt << color rows by row state;
dt << color rows by row state( 0 );
:age << Set Property( "Color Gradient", {"White to Blue", Range( 40, 80 )} );
:age << color cell by value( 1 );
:size << set property( "Value Colors", {"Large" = red, "Medium" = yellow, "Small" = gray} );
:size << color cell by value;
:size << color cell by value( 0 );
:sex << color cells( "green", {1, 5, 8} );
:sex << color cells( "white", {11} );
:sex << color cells( "black", {1, 11} );
vc = Char( :age << Get Property( "Color Gradient" ) );
vc = :size << Get Property( "Value Colors" );
Code Explanation:
- Open data table;
- Color by marital status.
- Marker by country.
- Color rows by row state.
- Disable row state coloring.
- Set age color gradient.
- Color age cells by value.
- Set size value colors.
- Color size cells by value.
- Disable size cell coloring.
Char using Compress selected columns
Summary: Runs data compression and property fetching for selected columns in a JMP data table, utilizing the Compress Selected Columns and Get Property functions.
Code:
dt = Open("data_table.jmp");
nlist = dt << get column names;
dt << Compress selected columns( nlist );
cert dprop = "List Check({\!"American\!", \!"European\!", \!"Japanese\!"})";
dprop = Char( dt:country << Get Property( "List Check" ) );
cert dprop = "List Check({\!"Married\!", \!"Single\!"})";
dprop = Char( dt:marital status << Get Property( "List Check" ) );
cert dprop = "List Check({\!"Large\!", \!"Medium\!", \!"Small\!"})";
dprop = Char( dt:size << Get Property( "List Check" ) );
cert dprop = "List Check({\!"Family\!", \!"Sporty\!", \!"Work\!"})";
dprop = Char( dt:type << Get Property( "List Check" ) );
cert dprop = "List Check({\!"Female\!", \!"Male\!"})";
dprop = Char( dt:sex << Get Property( "List Check" ) );
Code Explanation:
- Open data table.
- Retrieve column names into nlist.
- Compress selected columns using nlist.
- Define cert dprop for American/European/Japanese.
- Fetch property of country column.
- Define cert dprop for Married/Single.
- Fetch property of marital status column.
- Define cert dprop for Large/Medium/Small.
- Fetch property of size column.
- Define cert dprop for Family/Sporty/Work.
- Fetch property of type column.
- Define cert dprop for Female/Male.
- Fetch property of sex column.
Char using Set Selected
Summary: Runs data table operations by selecting columns, compressing selected columns, and retrieving properties for 'size' and 'type' columns.
Code:
dt = Open("data_table.jmp");
dt:size << Set Selected( 1 );
dt:type << Set Selected( 1 );
dt << compress selected columns;
cert dprop = "List Check({\!"Large\!", \!"Medium\!", \!"Small\!"})";
dprop = Char( dt:size << Get Property( "List Check" ) );
cert dprop = "List Check({\!"Family\!", \!"Sporty\!", \!"Work\!"})";
dprop = Char( dt:type << Get Property( "List Check" ) );
Code Explanation:
- Open data table;
- Select "size" column.
- Select "type" column.
- Compress selected columns.
- Define "cert dprop" for "Large", "Medium", "Small".
- Retrieve "size" column property.
- Define "cert dprop" for "Family", "Sporty", "Work".
- Retrieve "type" column property.
Char using Try
Example 1
Summary: Runs the retrieval and processing of data table properties, including list check, range check, value labels, and formula, before closing the table without saving.
Code:
dt = Open("data_table.jmp");
l = 0;
c = 0;
v = 0;
f = 0;
Try( l = Char( dt:Region << Get List Check ) );
Try( c = Char( dt:Region << Get Range Check ) );
Try( v = Char( dt:Region << Get Value Labels ) );
Try( f = Char( dt:Region << Get Formula ) );
Close( dt, nosave );
cert v = [17, 17, 17, 16, 16, 16, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 15, 15, 15, 15, 15, 15, 15];
Code Explanation:
- Open data table;
- Initialize variables l, c, v, f.
- Try getting list check for Region.
- Try getting range check for Region.
- Try getting value labels for Region.
- Try getting formula for Region.
- Close table without saving.
- Define certificate values array.
Example 2
Summary: Runs the retrieval and initialization of data table regions, including list check, range check, value labels, and formula.
Code:
dt = Open("data_table.jmp");
l = 0;
c = 0;
v = 0;
f = 0;
Try( l = Char( dt:Region << Get List Check ) );
Try( c = Char( dt:Region << Get Range Check ) );
Try( v = Char( dt:Region << Get Value Labels ) );
Try( f = Char( dt:Region << Get Formula ) );
Code Explanation:
- Open data table;
- Initialize variables l, c, v, f to 0.
- Try getting Region list check.
- Try getting Region range check.
- Try getting Region value labels.
- Try getting Region formula.
Char using New Data View
Summary: Process of retrieving window titles containing 'data_table' from a JMP data table, utilizing a For loop to iterate through all windows.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", invisible );
dt << New Data View();
xx = Window();
winlist = {};
For( i = 1, i < N Items( xx ) + 1, i++,
If( Char( xx[i] ) == "DisplayBox[HeadBox]",
winname = xx[i] << get window title;
If( Contains( winname, "data_table" ),
Insert Into( winlist, winname )
);
)
);
Code Explanation:
- Open data table.
- Create new data view.
- Retrieve all windows.
- Initialize window list.
- Loop through all windows.
- Check for HeadBox display box.
- Get window title.
- Check if title contains "Cities".
- Insert matching titles into list.
- End loop.
Char using Go to
Summary: Creates and configures a new JMP table with a 'Date' column, formatting and modeling options, and a 'Month' column with character values.
Code:
dt = Open("data_table.jmp");
i = 2;
dt << Go to( i );
selCol = dt << get Selected columns;
Close( dt, no save );
dt = New Table( "Test" );
col = dt << New Column( "Date", numeric, continuous );
col << input format( "m/d/y" );
col << Format( "y/m/d" );
fcol = Char( col << get format );
incol = Char( col << get input format );
Close( dt, no save );
dt = New Table( "test",
Add Rows( 11 ),
New Column( "Month",
Character,
Nominal,
Set Values(
{"05/2012", "06/2012", "07/2012", "08/2012", "09/2012", "10/2012", "11/2012", "12/2012", "01/2013", "02/2013", "03/2013"}
)
)
);
Column( dt, 1 ) << Data Type( Numeric ) << Format( "M/Y", 7 ) << Set Modeling Type( Continuous );
t = Column( dt, 1 )[1];
Code Explanation:
- Open data table.
- Go to second row.
- Get selected columns.
- Close data table without saving.
- Create new table named "Test".
- Add "Date" column with numeric format.
- Set input format for "Date" column.
- Set display format for "Date" column.
- Retrieve column formats.
- Create new table named "test" with 11 rows.
- Add "Month" column with character values.
- Convert "Month" column to numeric.
- Set format for "Month" column.
- Set modeling type for "Month" column.
- Retrieve first value from "Month" column.
Char using Column
Example 1
Summary: Runs property setting operations on a column in a JMP data table, demonstrating various syntax and formatting options.
Code:
dt = Open("data_table.jmp");
dc = Column( dt, "age" );
dc << Set Property( Any, Eval(), Any );
Try( dc << Set Property() );
dc << Set Property( [] );
dc << Set Property( {} );
dc << Set Property( foo, foo );
dc << Set Property( "", {} );
dc << Set Property( Eval() );
Close( dt, no save );
cert f = "Format(\!"Best\!", 1)";
dt = New Table( "Ding", Add Rows( 3 ), New Column( "MyCol", Numeric, Continuous, Format( "", 1 ), Set Values( [1, 2, 3] ) ) );
f = Char( dt:mycol << Get Format );
Code Explanation:
- Open data table.
- Assign age column to dc.
- Set property on age column.
- Try setting property on age column.
- Set property on age column.
- Set property on age column.
- Set property on age column.
- Set property on age column.
- Close data table without saving.
- Define format string.
- Create new data table.
- Get format of MyCol column.
Example 2
Summary: Configures a column's List Check property with a predefined list of values, retrieving and converting the selected value to character.
Code:
dt = Open("data_table.jmp");
mylist = {"F", "M"};
col = Column( 3 );
col << Set Property( "List Check", mylist );
charval = Char( col << Get Property( "List Check" ) );
Code Explanation:
- Open data table;
- Define gender list {"F", "M"}.
- Select third column.
- Set column's List Check property.
- Retrieve List Check property value.
- Convert property value to character.
Example 3
Summary: Creates a marker segment graph to visualize height and age data, utilizing the Get Values and New Window functions.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", invisible );
xx = Column( "height" ) << Get Values;
aa = [=> 0];
sz = Column( "age" ) << get values;
yy = J( N Rows( xx ), 1, 0 );
For( ii = 1, ii <= N Rows( xx ), ii++,
aa[xx[ii]]++;
yy[ii] = aa[xx[ii]];
);
nw24 = New Window( "Marker Seg Example",
g = Graph Box(
Frame Size( 300, 120 ),
X Scale( Min( xx ) - 5, Max( xx ) + 5 ),
Y Scale( 0, 10 ),
Marker Seg( xx, yy, Row States( dt ), Sizes( sz ) )
)
);
frame = g[FrameBox( 1 )];
seg = (frame << Find Seg( "Marker Seg" ));
frame_db = Char( seg << Frame );
Code Explanation:
- Open data table.
- Retrieve height column values.
- Initialize age count array.
- Retrieve age column values.
- Create zero-initialized output array.
- Loop through each row.
- Increment height count.
- Assign count to output array.
- Create new window.
- Add graph box with marker segments.
Char using Set Display Width
Summary: Formats and displays the 'Order Date' column in a JMP data table, doubling its width and applying a custom date format.
Code:
dt = Open("data_table.jmp");
:Order Date << Set Selected;
w = :Order Date << Get Display Width;
:Order Date << Set Display Width( 2 * w );
:Order Date << Format( "Custom", Formula( Char( Year( value ) ) || "W" || Substr( Char( 100 + Week Of Year( value ) ), 2 ) ), 10 );
dt << Go to row( 5 );
r = dt << get rows( {5} );
Code Explanation:
- Open data table.
- Select "Order Date" column.
- Get display width of column.
- Double the display width.
- Set custom format for date.
- Go to row number 5.
- Get row number 5.
Char using Run Script
Summary: Process of running a Distribution analysis, sorting a table box by column, and evaluating a parsed script.
Code:
dt = Open("data_table.jmp");
dist = dt << Run Script( "Distribution" );
(Report( dist )[Table Box( 3 )]) << Sort by Column( 2, 1 );
scr = Collapse Whitespace( Char( dist << Get Script ) );
dist2 = Eval( Parse( scr ) );
Code Explanation:
- Open data table;
- Run Distribution analysis.
- Sort third table box by second column.
- Extract script from distribution.
- Collapse whitespace in script.
- Evaluate parsed script.
Char using If
Example 1
Summary: Fits a model, generating prediction formulas, and publishing confidence limits in JMP Pro.
Code:
If( Contains( JMP Product Name(), "Pro" ) > 0,
dt = Open("data_table.jmp");
n1 = N Items( dt << get column names( string ) );
obj = dt << Run Script( "Fit Model" );
obj << Prediction Formula( 1 );
pred formula1 = Char( dt:Pred Formula weight << get formula( 1 ) );
obj << Parameterized Formula( 1 );
pred param formula1 = (dt:Pred Param Formula weight << get formula( 1 ));
pred param1 = dt:Pred Param Formula weight << get values( 1 );
obj << StdErr Pred Formula( 1 );
stderr pred formula1 = Char( dt:PredSE weight << get formula( 1 ) );
obj << Mean Confidence Limit Formula( 1 );
mean ci 1 = (dt:Lower 95% Mean weight << get values) || (dt:Upper 95% Mean weight << get values);
obj << Indiv Confidence Limit Formula( 1 );
indiv ci 1 = (dt:Lower 95% Indiv weight << get values) || (dt:Upper 95% Indiv weight << get values);
dt << Delete Columns( n1 + 1 :: N Cols( dt ) );
depot1 = obj << Publish Prediction Formula( 1 );
depot1 << Run Script( 1 );
pred formula2 = Char( dt:Pred Formula weight << get formula( 1 ) );
depot2 = obj << Publish Parameterized Formula( 1 );
depot2 << Run Script( 1 );
pred param formula2 = (dt:Pred Param Formula weight << get formula( 1 ));
pred param2 = dt:Pred Param Formula weight << get values( 1 );
depot3 = obj << Publish Standard Error Formula( 1 );
depot3 << Run Script( 1 );
stderr pred formula2 = Char( dt:PredSE weight << get formula( 1 ) );
depot4 = obj << Publish Mean Confid Limit Formula( 1 );
depot4 << Run Script( 1 );
mean ci 2 = (dt:Lower 95% Mean weight << get values) || (dt:Upper 95% Mean weight << get values);
depot5 = obj << Publish Indiv Confid Limit Formula( 1 );
depot5 << Run Script( 1 );
indiv ci 2 = (dt:Lower 95% Indiv weight << get values) || (dt:Upper 95% Indiv weight << get values);
Close( dt, no save );
Window( "Formula Depot" ) << close window( 1 );
);
Code Explanation:
- Check if JMP is Pro.
- Open data table;
- Count initial columns.
- Run Fit Model script.
- Set prediction formula.
- Get prediction formula.
- Set parameterized formula.
- Get parameterized formula and values.
- Set standard error formula.
- Get standard error formula.
- Set mean confidence limit formula.
- Get mean confidence limits.
- Set individual confidence limit formula.
- Get individual confidence limits.
- Delete new columns.
- Publish prediction formula.
- Run published prediction formula.
- Get updated prediction formula.
- Publish parameterized formula.
- Run published parameterized formula.
- Get updated parameterized formula and values.
- Publish standard error formula.
- Run published standard error formula.
- Get updated standard error formula.
- Publish mean confidence limit formula.
- Run published mean confidence limit formula.
- Get updated mean confidence limits.
- Publish individual confidence limit formula.
- Run published individual confidence limit formula.
- Get updated individual confidence limits.
- Close data table without saving.
- Close Formula Depot window.
Example 2
Summary: Process of running a Repeated Measures Model script in JMP Pro, generating prediction formulas and publishing conditional and standard error formulas.
Code:
If( Contains( JMP Product Name(), "Pro" ) > 0,
dt = Open("data_table.jmp");
n1 = N Items( dt << get column names( string ) );
obj = dt << Run Script( "Repeated Measures Model" );
obj << Prediction Formula( 1 );
pred formula1 = (dt:Pred Formula miles << get formula( 1 ));
pred formula1 eval = dt:Pred Formula miles << get values;
obj << Parameterized Formula( 1 );
pred param formula1 = (dt:Pred Param Formula miles << get formula( 1 ));
pred param1 = dt:Pred Param Formula miles << get values( 1 );
obj << Conditional Pred Formula( 1 );
cond pred formula1 = Char( dt:Cond Pred Formula miles << get formula( 1 ) );
obj << StdErr Pred Formula( 1 );
stderr pred formula1 = Char( dt:PredSE miles << get formula( 1 ) );
dt << Delete Columns( n1 + 1 :: N Cols( dt ) );
depot1 = obj << Publish Prediction Formula( 1 );
depot1 << Run Script( 1 );
pred formula2 = (dt:Pred Formula miles << get formula( 1 ));
pred formula2 eval = dt:Pred Formula miles << get values;
depot2 = obj << Publish Parameterized Formula( 1 );
depot2 << Run Script( 1 );
pred param formula2 = (dt:Pred Param Formula miles << get formula( 1 ));
pred param2 = dt:Pred Param Formula miles << get values( 1 );
depot3 = obj << Publish Conditional Formula( 1 );
depot3 << Run Script( 1 );
cond pred formula2 = Char( dt:Cond Pred Formula miles << get formula( 1 ) );
depot4 = obj << Publish Standard Error Formula( 1 );
depot4 << Run Script( 1 );
stderr pred formula2 = Char( dt:PredSE miles << get formula( 1 ) );
Close( dt, no save );
Window( "Formula Depot" ) << close window( 1 );
);
Code Explanation:
- Check if JMP Pro is installed.
- Open data table.
- Count initial columns.
- Run "Repeated Measures Model" script.
- Set prediction formula.
- Get prediction formula for "miles".
- Evaluate prediction formula.
- Set parameterized formula.
- Get parameterized formula for "miles".
- Get parameter value.
- Set conditional prediction formula.
- Get conditional formula as character.
- Set standard error formula.
- Get standard error formula as character.
- Delete new columns.
- Publish prediction formula.
- Run published prediction formula.
- Get updated prediction formula.
- Evaluate updated prediction formula.
- Publish parameterized formula.
- Run published parameterized formula.
- Get updated parameterized formula.
- Get updated parameter value.
- Publish conditional formula.
- Run published conditional formula.
- Get updated conditional formula.
- Publish standard error formula.
- Run published standard error formula.
- Close data table without saving.
- Close "Formula Depot" window.
Char using Add Rows
Summary: Creates a new data table with 125 rows, featuring columns for Wafer ID, Test Location, Bonding Force (N), Temperature (°C), Thickness (µm), Time (s), and Operator, with formulas generating random values and deleting formulas from columns 1 to 9.
Code:
Names Default To Here (1):
random reset (1234);
// Create a new data table
dt = New Table( "Wafer Bonding Data",
Add Rows( 25*5 ),
New Column( "Wafer ID",
Character,
Nominal,
Formula( "W_"||char(Sequence(1,25,1,5)) ) // Unique wafer ID for each row
),
New Column ("Test Location",
Numeric,
Nominal,
Formula( Sequence (1,5))
),
New Column( "Bonding Force (N)",
Numeric,
Continuous,
Format( "Fixed Dec", 1 ),
Formula( Random Normal( 100, 1 ) ) // Random values around 100 N
),
New Column( "Temperature (°C)",
Numeric,
Continuous,
Format( "Fixed Dec", 1 ),
Formula( Random Normal( 200, 0.5 ) ) // Random values around 200 °C
),
New Column( "Thickness (µm)",
Numeric,
Continuous,
Format( "Fixed Dec", 1 ),
Formula( Random Normal( 700, 0.5 ) ) // Random values around 700 µm
),
New Column( "Alignment Error (µm)",
Numeric,
Continuous,
Format( "Fixed Dec", 1 ),
Formula( Random Uniform( 0.4, 0.8 ) ) // Uniformly distributed between 0.4 and 0.8
),
New Column( "Bond Strength (MPa)",
Numeric,
Continuous,
Format( "Fixed Dec", 1 ),
Formula( Random Normal( 50, 0.5 ) ) // Random values around 50 MPa
),
New Column( "Time (s)",
Numeric,
Continuous,
Formula( 30 ) // Fixed value of 30 seconds
),
New Column( "Operator",
Character,
Nominal,
Formula( If( Row() <= 60, "Operator A", "Operator B" ) ) // Alternating operators
)
);
for each ({i}, 1::9,
column (i) << delete formula
);
Code Explanation:
- Set default names scope.
- Reset random seed.
- Create new data table.
- Add 125 rows.
- Add "Wafer ID" column.
- Add "Test Location" column.
- Add "Bonding Force (N)" column.
- Add "Temperature (°C)" column.
- Add "Thickness (µm)" column.
- Add "Alignment Error (µm)" column.
- Add "Bond Strength (MPa)" column.
- Add "Time (s)" column.
- Add "Operator" column.
- Delete formulas from columns 1 to 9.
Char using For Each
Summary: Creates 10 Excel workbooks with 2 worksheets each, using data from two open data tables and specifying worksheet names.
Code:
Names Default To Here( 1 );
//make 10 workbooks with 2 worksheets in each
lstdt = {};
lstdt[1] = Open("data_table.jmp");
lstdt[2] = Open("data_table.jmp");
For Each( {i}, 1 :: 10,
Create Excel Workbook(
"$DESKTOP/Sample Excel Workbook" || Char( i ) || ".xlsx",
lstdt,
{"Class", "Abrasion"}
)
);
Code Explanation:
- Set default names location.
- Initialize empty list.
- Open data table;
- Open data table;
- Loop 10 times.
- Create Excel workbook.
- Name workbook uniquely.
- Include datasets in workbook.
- Specify worksheet names.
- End loop.