BookmarkSubscribe
Choose Language Hide Translation Bar
Highlighted
Jaz
Jaz
Community Trekker

RE: Copying an Existing Column and all its Values to a Different Data Table

Hi, 

 

I'm trying to add an existing column from my dt table so that it appears as the first column in my data table. The following two parts work in the sense that they add a new column called "Process Instructions" to the dc data table but none of the values appear in the cells, instead dots do. 

 

First Part: 

Names Default To Here(1);
Clear Log(); 
Clear Globals();  
dc = Open("prototype raw data from measurements.jmp");
dt = Open("Automatically Logged Data.jmp");
vals = (Column(dt, "Instructions")<<getValues);
dc << New Column( "Process Instructions", Multiple Response, set values(vals)) ;
dc << Move Selected Columns( {"Process Instructions"}, To First );

Running the first part of code makes sciptable[] appear in the log- what does this mean? 

 

Second part: 

Names Default To Here(1);
Clear Log(); 
Clear Globals();  
dc = Open("prototype raw data from measurements.jmp");
dt = Open("Automatically Logged Data.jmp");
dc << New Column("Process Instructions", formula(dt:newInstructionsColumn));

The second bit of code however, gives me the following errors:

Column Process Instructions Formula Interrupted
Scoped data table access requires a data table column or variable 1 times At rows: {1} Operation: dt:newInstructionsColumn, dt:newInstructionsColumn
Formula evaluation errors have been ignored

Note: I'm aware that I probably shouldn't be using the formula function in this way but it seems to be partially working.  

 

Any help would be appreciated. 

0 Kudos
4 REPLIES 4
txnelson
Super User

RE: Copying an Existing Column and all its Values to a Different Data Table

 The issue is, that you are not declaring the column as a character column, which is what I am assuming your column needs to be.  I apparently confused you with the example I gave yesterday.  In that example, the column being copied was of the Modeling Type, "Multiple Response".  I am assuming your instructions column needs to be a Modeling Type, "Character".  Try the following code:

Names Default To Here(1);
Clear Log(); 
Clear Globals();  
dc = Open("prototype raw data from measurements.jmp");
dt = Open("Automatically Logged Data.jmp");
vals = (Column(dt, "Instructions")<<getValues);
dc << New Column( "Process Instructions", Character, set values(vals)) ;
dc << Move Selected Columns( {"Process Instructions"}, To First );

The code can also be shortend to:

Names Default To Here(1);
Clear Log(); 
Clear Globals();  
dc = Open("prototype raw data from measurements.jmp");
dt = Open("Automatically Logged Data.jmp");
dc << New Column("Process Instructions", character, set values(dt:newInstructionsColumn << get values ));
Move Selected Columns( {"Process Instructions"}, To First );

 

Jim
0 Kudos
Jaz
Jaz
Community Trekker

RE: Copying an Existing Column and all its Values to a Different Data Table

Your message was empty? 

0 Kudos
Jaz
Jaz
Community Trekker

RE: Copying an Existing Column and all its Values to a Different Data Table

Hi, 

 

I tried using your code, and you're right in that my instruction column needs to be of the type character but it still doesn't work and outputs no values in the column. I was also wondering what the purpose of Names Default To Here(1) was in this case? 

 

Thanks. 

0 Kudos
txnelson
Super User

RE: Copying an Existing Column and all its Values to a Different Data Table

You can find documentation on Name Spaces and the Scoping of variables in the Scripting Guide.  That will give you the description and purpose for the "Names Default to Here( 1 );" statement.  I strongly recomment you read through it.

     Help==>Books==>Scripting Guide

 

Concerning the code not working, can you please attach samples of your 2 data tables?

Jim
0 Kudos