BookmarkSubscribe
Choose Language Hide Translation Bar
jpmontagne
Community Trekker

Re: Script to export AIC into new data table

EUREKA!!! Thanks Jeff, Mark and Ian! You guys taught me a lot in a short time, and gave me the solution that will save me hours of unnecessary click,copy,pasting!

Now, if any of you know how to add a column for the warning text when models don't converge, that would be icing on the cake. But I'm happy with what we've accomplished!

0 Kudos
jwong7
Community Trekker

Using VBA Macro to import data to JMP and return JMP results back to Excel sheet on Weibull Analysis

Hi guys,

First of all i would like to thank you for sharing your scripting findings and it helped me to be able to automate my data query process. i am using VBA-Macro excel to copy my table into JMP to perform the Weibull analysis and obtain the Scale & Shape values and copy out into my VBA -Macro excel file.Below are the code i used. Hope it will be helpful for others as well.

 

VBA-Macro Excel.

Sub JMP()
Dim app As JMP.Application
Dim doc As JMP.Document
Set app = CreateObject("JMP.Application")
app.Visible = True
Set doc = app.OpenDocument("C:\Users\ABC\Desktop\WS.jsl")

end sub 

 

JSL scripts ( saved as WS.jsl format) 

//!       <<<if you want to automatically run the JSL scripts below and it must be at your 1st line in your JSL file>>>. 

dt = Open( "C:\Users\ABC\Desktop\Book1.xlsm" );   <<< JSL will open the excel file into JMP data table to execute the weibull analysis below>>>
fm = Life Distribution(
Y( :Name( "TTF,Hr" ) ),
Censor( :Censor ),
Censor Code( 1 ),
Freq( :Freq ),
<<Fit Weibull,
Confidence Interval Method( Likelihood ),
<<Set Scale( Nonparametric ),
<<Suppress Plot( Nonparametric ),
Interval Type( Simultaneous ),
<<Set Scriptables(
{Probability Paper( Profiler( 1, Confidence Intervals( 1 ), Term Value( Name( "TTF,Hr" )(4846.6174375, Lock( 0 ), Show( 1 )) ) ) ),
Weibull Distribution( Profiler( 1, Confidence Intervals( 1 ), Term Value( Name( "TTF,Hr" )(4846.6, Lock( 0 ), Show( 1 )) ) ) ),
Weibull Quantile( Profiler( 1, Confidence Intervals( 1 ), Term Value( Probability( 0.5, Lock( 0 ), Show( 1 ) ) ) ) ),
Weibull Hazard( Profiler( 1, Confidence Intervals( 1 ), Term Value( Name( "TTF,Hr" )(4846.6, Lock( 0 ), Show( 1 )) ) ) ),
Weibull Density( Profiler( 1, Term Value( Name( "TTF,Hr" )(4846.6, Lock( 0 ), Show( 1 )) ) ) ), Custom Estimation( Weibull, 0 )}
),
SendToReport(
Dispatch( {"Compare Distributions"}, "Life Distribution", FrameBox, {Grid Line Order( 2 ), Reference Line Order( 3 )} ),
Dispatch( {"Statistics", "Model Comparisons"}, "", TableBox, {Sort By Column( 2, 1 )} )
)
);

// To automatically copy out the Parametic Estimate data into new data table  (eg: untitled.jmp format) 
fmrep = fm << Report;
fmrep[Outline Box("Parametric Estimate ?" )][Table Box( 1 )] << make combined data table;
dt1 = Current Data Table();
dt1 << SaveAs( "c:\Users\ABC\Desktop\AAA.xlsx" ); // to save the untitled.jmp file as excel file ( in this case i naed it as AAA.xlsx) at desktop location. 
Close( dt, No Save );
Close( dt1, No Save );

 

The above scripts is working perfectly for me. 

 

Just thought to contribute back to this community with my recent finding & learning. 

Thanks!

Jim

 

0 Kudos