cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-45756%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9AJSL%EF%BC%9A%E5%A4%8D%E5%88%B6%E6%95%B0%E6%8D%AE%E8%A1%A8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-45756%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%8F%A6%E4%B8%80%E7%A7%8D%E6%96%B9%E6%B3%95%E6%98%AF%E7%94%A8%E6%89%80%E6%9C%89%E8%A1%8C%E5%92%8C%E6%89%80%E6%9C%89%E5%88%97%E5%AF%B9%E8%A1%A8%E8%BF%9B%E8%A1%8C%E5%AD%90%E9%9B%86%E5%8C%96%E3%80%82%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%20%22%24SAMPLE_DATA%5CBig%20Class.jmp%22%20)%3B%0Adt_copy%20%3D%20dt%20%26lt%3B%26lt%3B%20Subset(%20All%20rows%2C%20Selected%20columns%20only(%200%20)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-45752%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9AJSL%EF%BC%9A%E5%A4%8D%E5%88%B6%E6%95%B0%E6%8D%AE%E8%A1%A8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-45752%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E8%BF%99%E6%98%AF%E4%B8%80%E7%A7%8D%E6%96%B9%E6%B3%95%EF%BC%9A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENamesDefaultToHere(1)%3B%0Adt1%20%3D%20Open(%22%24SAMPLE_DATA%2FBig%20Class.jmp%22)%3B%0Adt2%20%3D%20Eval(dt1%20%26lt%3B%26lt%3B%20getScript)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-45750%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9AJSL%EF%BC%9A%E5%A4%8D%E5%88%B6%E6%95%B0%E6%8D%AE%E8%A1%A8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-45750%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E9%A1%BA%E4%BE%BF%E8%AF%B4%E4%B8%80%E5%8F%A5%EF%BC%8C%E5%AF%B9%E4%BA%8E%E8%A2%AB%E9%98%BB%E6%AD%A2%E7%9A%84%E4%B8%8D%E5%8F%AF%E8%A7%81%E5%91%BD%E4%BB%A4%EF%BC%8C%E6%88%91%E4%BB%AC%E6%B7%B1%E8%A1%A8%E6%AD%89%E6%84%8F%E3%80%82%20%E8%BF%99%E5%AF%B9%E6%88%91%E7%9A%84%E9%97%AE%E9%A2%98%E5%B9%B6%E4%B8%8D%E9%87%8D%E8%A6%81%E3%80%82%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-614932%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9AJSL%EF%BC%9A%E5%A4%8D%E5%88%B6%E6%95%B0%E6%8D%AE%E8%A1%A8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-614932%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%EF%BC%8C%3C%2FP%3E%3CP%3E%E6%88%91%E4%BB%AC%E5%88%9A%E5%88%9A%E5%9C%A8%E4%BD%BF%E7%94%A8%E4%B8%A4%E4%B8%AA%E5%B5%8C%E5%A5%97%E7%9A%84%E2%80%9CFor%20each%20row%E2%80%9D%E5%91%BD%E4%BB%A4%E6%97%B6%E4%BD%BF%E7%94%A8%E5%BB%BA%E8%AE%AE%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E2%80%9CEval(dt%20%26lt%3B%26lt%3B%20Get%20script)%E2%80%9D%E9%81%87%E5%88%B0%E4%BA%86%E9%94%99%E8%AF%AF%E3%80%82%3C%2FP%3E%3CP%3E%E5%B0%86%E5%85%B6%E6%9B%BF%E6%8D%A2%E4%B8%BA%E2%80%9Cdt%26lt%3B%26lt%3B%20%E5%AD%90%E9%9B%86%E2%80%9D%E5%8F%AF%E4%BD%BF%E8%AF%A5%E5%8A%9F%E8%83%BD%E6%AD%A3%E5%B8%B8%E5%B7%A5%E4%BD%9C%E3%80%82%20%E6%89%80%E4%BB%A5%E8%BF%99%E4%B8%A4%E4%B8%AA%E5%91%BD%E4%BB%A4%E4%B9%8B%E9%97%B4%E4%B8%80%E5%AE%9A%E6%9C%89%E5%8C%BA%E5%88%AB%E3%80%82%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E6%AD%A4%E8%87%B4%EF%BC%8C%3C%2FP%3E%3CP%3E%E6%89%98%E9%A9%AC%E6%96%AF%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-45749%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EJSL%EF%BC%9A%E5%A4%8D%E5%88%B6%E6%95%B0%E6%8D%AE%E8%A1%A8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-45749%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E8%BF%99%E5%8F%AF%E8%83%BD%E9%9D%9E%E5%B8%B8%E7%AE%80%E5%8D%95%EF%BC%8C%E4%BD%86%E6%88%91%E5%B7%B2%E7%BB%8F%E9%98%85%E8%AF%BB%E4%BA%86%E8%84%9A%E6%9C%AC%E6%8C%87%E5%8D%97%EF%BC%8C%E5%B9%B6%E4%B8%94%E6%90%9C%E7%B4%A2%E4%BA%86%E7%A4%BE%E5%8C%BA%E8%AE%A8%E8%AE%BA%EF%BC%8C%E4%BD%86%E6%B2%A1%E6%9C%89%E4%BB%BB%E4%BD%95%E8%BF%90%E6%B0%94%EF%BC%8C%E6%89%80%E4%BB%A5%E8%BF%99%E9%87%8C%E6%98%AF%EF%BC%9A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E6%88%91%E6%AD%A3%E5%9C%A8%E5%B0%9D%E8%AF%95%E5%A4%8D%E5%88%B6%E4%B8%80%E4%B8%AA%E5%8C%85%E5%90%AB%E5%80%BC%E3%80%81%E5%88%97%E5%B1%9E%E6%80%A7%E7%AD%89%E7%9A%84%E5%AE%8C%E6%95%B4%E6%95%B0%E6%8D%AE%E8%A1%A8%E3%80%82%20%E6%9C%89%E8%BF%99%E4%B8%AA%E5%91%BD%E4%BB%A4%E5%90%97%EF%BC%9F%20%E6%88%91%E5%B0%9D%E8%AF%95%E5%B0%86%E4%B8%80%E4%BA%9B%E4%B8%9C%E8%A5%BF%E7%BB%84%E5%90%88%E5%9C%A8%E4%B8%80%E8%B5%B7%EF%BC%9A%3C%2FP%3Edt%3D%E5%BD%93%E5%89%8D%E6%95%B0%E6%8D%AE%E8%A1%A8()%3B%20colNames%20%3D%20dt%20%26lt%3B%26lt%3B%20%E8%8E%B7%E5%8F%96%E5%88%97%E5%90%8D%E7%A7%B0(%20String%20)%3B%20ndt%20%3D%20New%20Table(%22%E7%BB%98%E5%88%B6%E6%95%B0%E6%8D%AE%22%2C%20%2F*%E4%B8%8D%E5%8F%AF%E8%A7%81%2C*%2F)%3B%20For%20(i%3D1%2C%20i%20%26lt%3B%3D%20NCols(dt)%2C%20i%2B%2B%2C%20New%20Column(colNames%5Bi%5D)%3B%20colProps%20%3D%20Column(dt%2C%20colNames%5Bi%5D)%20%26lt%3B%26lt%3B%20%E8%8E%B7%E5%8F%96%E5%88%97%E5%B1%9E%E6%80%A7%3B%20Column(%20ndt%2C%20colNames%5Bi%5D%20)%20%26lt%3B%26lt%3B%20%E6%B7%BB%E5%8A%A0%E5%88%97%E5%B1%9E%E6%80%A7(%20colProps%20)%3B%20)%3B%20ndt%20%26lt%3B%26lt%3B%20%E6%B7%BB%E5%8A%A0%E8%A1%8C(NRows(dt))%3B%20For%20(j%3D1%2C%20j%20%26lt%3B%3D%20NCols(dt)%2C%20j%2B%2B%2C%20colVals%20%3D%20Column(dt%2C%20colNames%5Bj%5D)%20%26lt%3B%26lt%3B%20%E8%8E%B7%E5%8F%96%E5%80%BC%3B%20Column(ndt%2C%20colNames%5Bj%5D)%20%26lt%3B%26lt%3B%20%E8%AE%BE%E7%BD%AE%E5%80%BC(%20colVals%20)%3B%20)%20%3B%3CP%3E%E7%84%B6%E8%80%8C%EF%BC%8C%E9%99%A4%E4%BA%86%E5%AF%B9%E4%BA%8E%E7%9B%B8%E5%BD%93%E7%AE%80%E5%8D%95%E7%9A%84%E4%B8%9C%E8%A5%BF%E6%9D%A5%E8%AF%B4%E8%BF%87%E4%BA%8E%E5%A4%8D%E6%9D%82%E4%B9%8B%E5%A4%96%EF%BC%8C%E5%AE%83%E4%B8%8D%E4%BC%9A%E5%A4%8D%E5%88%B6%E5%AD%97%E7%AC%A6%E6%95%B0%E6%8D%AE%EF%BC%8C%E5%9B%A0%E4%B8%BA%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E6%98%BE%E7%84%B6%E4%B8%8D%E5%8C%85%E5%90%AB%E5%9C%A8%E5%88%97%E5%B1%9E%E6%80%A7%E4%B8%AD%E3%80%82%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E8%B0%A2%E8%B0%A2%EF%BC%8C%3C%2FP%3E%3CP%3E%E7%BA%A6%E7%BF%B0%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
JPKO
Level III

JSL: Copy data table

This is probably really simple, but I've been through the scripting guide and I've searched the community discussions without any luck so here goes:

 

I'm trying to copy a comple data table with values, column properties and all. Is there a command for this? I tried to hack something together:

dt=current data table();

colNames = dt << Get Column Names( String );

ndt = New Table("Plotting Data", /*invisible,*/);

For (i=1, i <= NCols(dt), i++,
	New Column(colNames[i]);
	colProps = Column(dt, colNames[i]) << Get Column Properties;
	Column( ndt, colNames[i]) << Add Column Properties( colProps );
);

ndt << Add Rows(NRows(dt));
For (j=1, j <= NCols(dt), j++,
	colVals = Column(dt, colNames[j]) << Get values;
	Column(ndt, colNames[j]) << Set values( colVals );
);

However besides being overly complicated for something rather simple, it won't copy character data because data type is apparently not included in column properties.

 

 

Thanks,

Johan

1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp
Level X

Re: JSL: Copy data table

Here's one way:

NamesDefaultToHere(1);
dt1 = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = Eval(dt1 << getScript);

View solution in original post

4 REPLIES 4
JPKO
Level III

Re: JSL: Copy data table

BTW sorry for the invisible command that's blocked out. It's not important for my question.
ian_jmp
Level X

Re: JSL: Copy data table

Here's one way:

NamesDefaultToHere(1);
dt1 = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = Eval(dt1 << getScript);

Re: JSL: Copy data table

Another way is to subset the table with all rows and all columns.

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt_copy = dt << Subset( All rows, Selected columns only( 0 ) );
Justin
ThomasDickel
Level III

Re: JSL: Copy data table

Hi, 

we just ran into an error using the proposed solution "Eval( dt << Get script)" while using two nested "For each row" commands.

Replacing this with the "dt<< Subset" made the function work. So there must be a difference between these two commands.

 

Best Regards,

Thomas

 

 

Recommended Articles