Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- JSL: Copy data table

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 11, 2017 5:57 AM
(1420 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 11, 2017 6:17 AM
(2775 views)

Solution

Here's one way:

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

3 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 11, 2017 5:58 AM
(1419 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 11, 2017 6:17 AM
(2776 views)

Here's one way:

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 11, 2017 6:36 AM
(1410 views)

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