I would like to ask JMP community to help me out on a custom way to export JMP table to excel.
Thanks!
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
I am not sure exactly what all you need with your code, but here is a simple script that creates your required subsets and saves them to an Excel workbook. If you need to save the jmp tables as separate tables, in addition to the workbook, you can do that with a simple loop after the workbook is created.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
cNa = dt << get column names;
xF = {};
For( c = 2, c <= N Col( dt ), c++,
d2 = dt << Subset(
All rows,
columns( dt:name, Column( dt, c ) ),
output table( Char( cNa[c] ) )
);
Insert Into( xF, d2 << get name );
);
close( dt, nosave );
Create Excel Workbook( "c:\TheWorkBook.xlsx", Eval( xF ), Eval( xF ) );
Hi @lwx228,
One resource within JMP that is very helpful is the Scripting Index platform under Help.
You'll want to use the Save As on your data table. After you've opened it and done whatever you want to it, you would do something like:
dt << Save As("Filepath\filename.xlsx")
You can have all sorts of extensions, csv, txt, etc. It then saves it according to the extension.
You can even create an Excel workbook with somethign like:
Create Excel Workbook("filepath\filename.xlsx",{"data table name 1", "data table name 2"}, {"Worksheet name 1", "Worksheet name 2"})
It sounds like what you want to do is something more like the last option.
Hope this helps!,
DS
I still don't get it.Not done.
Thanks!
Create Excel Workbook( "c:\MyWorkbook.xlsx", {"Big Class", "Abrasion"}, {"Big", "Abrasive"} );
This example should work in JMP 13 or later
names default to here(1);
open("$SAMPLE_DATA/big class.jmp");
open("$SAMPLE_DATA/airline delays.jmp");
Create Excel Workbook(
"$TEMP\TheWorkBook.xlsx",
{"big class", "Airline delays"},
{"Big", "Airline"}
);
wait(0);
close(data table("Big Class"), nosave);
close(data table("airline delays"), nosave);
wait(4);
open("$TEMP\TheWorkBook.xlsx");
dt = Current Data Table();di="c:\";
cNa=dt<<get column names;xF=As List(cNa[2 ::ncol(dt)]);
for(c=2,c<=ncol(dt),c++,
current data table(dt);ca=Column(c)<<Get Name;
d2 =dt<< Subset( All rows, columns( :name, Column(c) ) );Wait(0);
d2<<Save(di ||ca ||".jmp" );
);
dt<<Close Window;
Create Excel Workbook("c:\TheWorkBook.xlsx",xF,xF);
xF is error
{"","","",""}
{,,,}
You need to evaluate the list:
names default to here(1);
open("$SAMPLE_DATA/big class.jmp");
open("$SAMPLE_DATA/airline delays.jmp");
dts = {"big class", "Airline delays"};
spreads = {"Big", "Airline"};
Create Excel Workbook(
"$TEMP\TheWorkBook2.xlsx",
eval( dts )
,
eval( spreads )
);
wait(0);
close(data table("Big Class"), nosave);
close(data table("airline delays"), nosave);
wait(4);
open("$TEMP\TheWorkBook2.xlsx");
I understand the full JSL is like this.
But can't it ——{"age","sex","height","weight"}——be generated automatically by code?This enables automation for different files.
Thanks!
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt = Current Data Table();di="c:\";
cNa=dt<<get column names;xF=As List(cNa[2 ::ncol(dt)]);
for(c=2,c<=ncol(dt),c++,
current data table(dt);ca=Column(c)<<Get Name;
d2 =dt<< Subset( All rows, columns( :name, Column(c) ) );Wait(0);
d2<<Save(di ||ca ||".jmp" );
);
dt<<Close Window;
Create Excel Workbook("c:\TheWorkBook.xlsx",{"age","sex","height","weight"},{"age","sex","height","weight"});