- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
saving script to data table issue
HI all,
I have written a script (a few hundred lines) that 1) opens an existing data table, 2) does a whole bunch of calculations and then 3) spits out a new data table with results from these calculations. Because I am continually improving the script, I want to make sure that I know which exact version of the script was used to create the new output data table and so thought of saving the whole script to the data table. I tried using NewDt<<save script to data table but this will only save as a script the line that created the NewDt, not the full script. Ideally I would like to save not only the script but also the original data table from which the NewDt was created. Any suggestions?
Regards and thanks, Yves
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: saving script to data table issue
Here is a simple script that will show you one way to do this
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
biv = dt << bivariate( x( :height ), y( :weight ) );
theScript = Char( biv << get script );
Eval( Parse( "\[dt<<new script("Saved Script",]\" || theScript || ");" ) );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: saving script to data table issue
Thanks Jim but I don't think that it solves my problem. My issue is more like the following:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
m = dt << Get All Columns As Matrix();
Several lines of matrix algebra with the columns of m producing various vectors y1, y2, y3
dt2=as table(y1, y2, y3);
I want to entire script above to be saved to dt2. Thanks again, Yves
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: saving script to data table issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: saving script to data table issue
That's the problem, the. script doesn't "come" from anywhere, it is simply all the lines I have written contained in my fictitious example. THis is what I can't figure out how to do! Thanks, Yves
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: saving script to data table issue
Here is a simple example of what you will have to do to create such a script. Components that you will not be able to get from JMP, you will have to add into theScript as you build it. Basically, you just concatenate it as you go. Then when done, you add it to the data table.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
dt = current data table();
theScript = "\[dt = current data table(); ]\";
If( try( dt:ratio << get name,"") == "",
dt<<new column("ratio", formula(:height/:weight))
);
theScript = theScript ||
"\[
If( try( dt:ratio << get name,"") == "",
dt<<new column("ratio", formula(:height/:weight))
);
]\";
biv = dt << bivariate( x( :ratio), y(:weight ) );
theScript = theScript || Char( biv << get script );
Eval( Parse( "\[dt<<new script("Saved Script",]\" || theScript || ");" ) );
I have also used a method where I first build the entire script as a literal string, and then save it as a script. Then I turn around and run the saved script, which then gives the results.
theScript = "\[
dt = current data table();
dt << bivariate( x(:weight), y(:height));
]\";
Eval( Parse( "\[dt<<new script("Saved Script2",]\" || theScript || ");" ) );
dt << run script("Saved Script2");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: saving script to data table issue
Many thanks I will try that! Your help much appreciated. Yves