RE: Copying an Existing Column and all its Values to a Different Data TableHi,
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></GETVALUES>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.
RE: Copying an Existing Column and all its Values to a Different Data TableYou 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?
RE: Copying an Existing Column and all its Values to a Different Data TableHi,
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.
RE: Copying an Existing Column and all its Values to a Different Data TableYour message was empty?
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></GETVALUES>
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 );