cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • We’re improving the Learn JMP page, and want your feedback! Take the survey
  • JMP monthly Newswire gives user tips and learning events. Subscribe
Choose Language Hide Translation Bar
shampton82
Level VII

Copy Table Script vs Get Script

Hey everyone,

I would like to copy the data table script from a summary table that was made and paste the code for it back into a Parent level table so that for later analysis I can call up the table without having to have saved the actual table somewhere else.  Basically trying to streamline the user experience of having to save multiple tables files and then reopen a bunch of files to use the analysis later.

 

I was thinking it would be along these lines but this is not working.  dt1 would be the summary table and dt2 would be the parent table.

So this would copy the data table script of dt1 and then place it as a table script in dt2.

source_script = dt1 << Copy Table Script();

Eval(EvalExpr(
	dt2 << New Script("SourceFromSummary",
		Expr(Name Expr(source_script))
	);
));

Any advice would be greatly appreciated!

 

Steve

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to use Copy Table Script()

In that case, << Get Script should work for you

Names Default To Here(1);

dt = New Table("ABC",
	Add Rows(10),
	New Column("A", Set Each Value(1)),
	New Column("B", Set Each Value(1)),
);

tablescript = dt << get script;

Eval(EvalExpr(
	dt << New Script("Create Copy", Expr(NameExpr(tablescript)));
));

jthi_0-1747507827597.png

If you really really wish to use Copy Table Script() (not sure why you would in case like this) use Get Clipboard() with Parse()

Names Default To Here(1);

dt = New Table("ABC",
	Add Rows(10),
	New Column("A", Set Each Value(1)),
	New Column("B", Set Each Value(1)),
);

dt << Copy Table Script();

Eval(EvalExpr(
	dt << New Script("Create Copy", Expr(Parse(Get Clipboard())));
));
-Jarmo

View solution in original post

6 REPLIES 6
jthi
Super User

Re: How to use Copy Table Script()

Do you wish to have the resulting Summary table or could you just utilize the script to create the summary table? Use << Get Script instead of Copy Table Script (it will copy it to clipboard)

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt_summary = dt << Summary(
	Group(:Age),
	subgroup(:sex),
	Mean(:Height),
	Include marginal statistics
);

summary_script = dt_summary << get script;

Eval(EvalExpr(
	dt << New Script("Summary", Expr(NameExpr(summary_script)));
));
-Jarmo
shampton82
Level VII

Re: How to use Copy Table Script()

Hey @jthi ,

I was hoping to have the resulting table.  The summary table being created is from a "make into data table" function and I'd like to be able to pull up the resulting table at a later time without having to rerun the analysis (which happens if I grab the embedded source table script).

jthi
Super User

Re: How to use Copy Table Script()

In that case, << Get Script should work for you

Names Default To Here(1);

dt = New Table("ABC",
	Add Rows(10),
	New Column("A", Set Each Value(1)),
	New Column("B", Set Each Value(1)),
);

tablescript = dt << get script;

Eval(EvalExpr(
	dt << New Script("Create Copy", Expr(NameExpr(tablescript)));
));

jthi_0-1747507827597.png

If you really really wish to use Copy Table Script() (not sure why you would in case like this) use Get Clipboard() with Parse()

Names Default To Here(1);

dt = New Table("ABC",
	Add Rows(10),
	New Column("A", Set Each Value(1)),
	New Column("B", Set Each Value(1)),
);

dt << Copy Table Script();

Eval(EvalExpr(
	dt << New Script("Create Copy", Expr(Parse(Get Clipboard())));
));
-Jarmo
shampton82
Level VII

Re: How to use Copy Table Script()

Nice!

I didn't realize that I could just use get script, I was trying to copy the red arrow action of copy table script so that was what I found in the scripting index.

 

Side question, is there a way to make a table a "child" of a parent table (like when you make a summary table and then link it)

shampton82_0-1747509759325.png

 

This would allow that when you close the parent table it will close the main table as well as be able to collapse the tables in the home window.

 

jthi
Super User

Re: How to use Copy Table Script()

To create "child tables" I think they have to be linked -> you would need to utilize Summary function instead of copying the table script with Link to Original Table(1). Other option would be to modify the table script and add << On Close to the original table when the table script is run but it can be difficult to make sure it will always point to the correct (original) table as Current Data Table() might not work as you think it will. Other thing you would have to take care of would be to keep on close script up to date when more and more tables are being created. For this you could manage the "references" with On Close via table variables or try to use << get on close to pull in last on close script and combine it with new table to close with.

-Jarmo
jthi
Super User

Re: How to use Copy Table Script()

You could also utilize Subscribe to Data Table List maybe with specific table names to know which ones to with the main table.

-Jarmo

Recommended Articles