cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
StevenCHowell
Level II

Save a JMP Custom Design to a csv file in a script?

 

I would like to create a script that generates a Custom Design then outputs the Design Matrix to a text file, e.g., '*.csv'.  Here is an example script that generates the Custom Design and a JMP Table containing the Design Matrix.

DOE(
    Custom Design,
    {Add Response( None, "My Response", ., ., . ),
    Add Factor( Discrete Numeric, {1, 2, 3, 4, 5, 6, 7, 8, 9}, "f1", 0 ),
    Add Factor( Discrete Numeric, {1, 2, 3, 4, 5}, "f2", 0 ),
    Add Factor( Blocking, 7, "day" ),
    Add Factor( Categorical, {"v1", "v2", "v3", "v3"}, "f3", 0 ),
    Set Random Seed( 123 ),
    Add Term( {1, 0} ),
    Add Term( {1, 1} ),
    Add Term( {2, 1} ),
    Add Term( {1, 1} ),
    Add Term( {2, 1} ),
    Add Term( {4, 1} ),
    Add Alias Term( {1, 2} ),
    Add Alias Term( {2, 2} ),
    Add Alias Term( {1, 1}, {2, 1} ),
    Add Alias Term( {1, 2} ),
    Add Alias Term( {2, 2} ),
    Add Alias Term( {1, 1}, {2, 1} ),
    Add Alias Term( {1, 1}, {4, 1} ),
    Add Alias Term( {4, 1}, {2, 1} ),
    Number of Starts( 581 ),
    Replicates( 3 ),
    Set Sample Size( 28 ),
    Optimality Criterion( 3 ),
    Make Design,
    Make Table}
);

I searched the JMP JSL Scripting guide without finding a solution.  In the Scripting Index, the "Data Table > Save,Save As" entry looks promising.  It has a example that says:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Save( "C:\Big Class.csv" );

I am not sure how to apply this.  After running the DOE script, the table is already open.  How do I get the handle for that table (`dt` in the examlpe) so I can then save it using `dt << Save( "C:\my\path\file.csv" )`?

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Save a JMP Custom Design to a csv file in a script?

I think the approach to externalize the "Make Table" message, and placing a handle on it's result is the easiest way to do this

DOEPlatform = DOE(
    Custom Design,
    {Add Response( None, "My Response", ., ., . ),
    Add Factor( Discrete Numeric, {1, 2, 3, 4, 5, 6, 7, 8, 9}, "f1", 0 ),
    Add Factor( Discrete Numeric, {1, 2, 3, 4, 5}, "f2", 0 ),
    Add Factor( Blocking, 7, "day" ),
    Add Factor( Categorical, {"v1", "v2", "v3", "v3"}, "f3", 0 ),
    Set Random Seed( 123 ),
    Add Term( {1, 0} ),
    Add Term( {1, 1} ),
    Add Term( {2, 1} ),
    Add Term( {1, 1} ),
    Add Term( {2, 1} ),
    Add Term( {4, 1} ),
    Add Alias Term( {1, 2} ),
    Add Alias Term( {2, 2} ),
    Add Alias Term( {1, 1}, {2, 1} ),
    Add Alias Term( {1, 2} ),
    Add Alias Term( {2, 2} ),
    Add Alias Term( {1, 1}, {2, 1} ),
    Add Alias Term( {1, 1}, {4, 1} ),
    Add Alias Term( {4, 1}, {2, 1} ),
    Number of Starts( 581 ),
    Replicates( 3 ),
    Set Sample Size( 28 ),
    Optimality Criterion( 3 ),
    Make Design}
);

dt = DOEPlatform<<make table;
dt << Save As(".........");
Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: Save a JMP Custom Design to a csv file in a script?

I think the approach to externalize the "Make Table" message, and placing a handle on it's result is the easiest way to do this

DOEPlatform = DOE(
    Custom Design,
    {Add Response( None, "My Response", ., ., . ),
    Add Factor( Discrete Numeric, {1, 2, 3, 4, 5, 6, 7, 8, 9}, "f1", 0 ),
    Add Factor( Discrete Numeric, {1, 2, 3, 4, 5}, "f2", 0 ),
    Add Factor( Blocking, 7, "day" ),
    Add Factor( Categorical, {"v1", "v2", "v3", "v3"}, "f3", 0 ),
    Set Random Seed( 123 ),
    Add Term( {1, 0} ),
    Add Term( {1, 1} ),
    Add Term( {2, 1} ),
    Add Term( {1, 1} ),
    Add Term( {2, 1} ),
    Add Term( {4, 1} ),
    Add Alias Term( {1, 2} ),
    Add Alias Term( {2, 2} ),
    Add Alias Term( {1, 1}, {2, 1} ),
    Add Alias Term( {1, 2} ),
    Add Alias Term( {2, 2} ),
    Add Alias Term( {1, 1}, {2, 1} ),
    Add Alias Term( {1, 1}, {4, 1} ),
    Add Alias Term( {4, 1}, {2, 1} ),
    Number of Starts( 581 ),
    Replicates( 3 ),
    Set Sample Size( 28 ),
    Optimality Criterion( 3 ),
    Make Design}
);

dt = DOEPlatform<<make table;
dt << Save As(".........");
Jim

Recommended Articles