Sum of a column where column name is stored in a variableHi,
I have a variable named as "target var" which stores the column name "diameter". When I do show(target_var), I get the output "target_var = :diameter". Now, I want to find the sum of the column whose name is stored in the variable "target_var". But when I do sum(eval(target_var)), I get "Column Disappeared{1}" in the log. Only when I do sum(diameter), I get the correct result. How can I sum the column using the variable target_var? Please help.Thanks!!
Re: Sum of a column where column name is stored in a variableThis works!! Thanks ih !! 
Re: Sum of a column where column name is stored in a variableTry saving the name of the first column as a string using << Get Name, and then specify the table and column name in the Col sum function. Here is an example:
//Open one table
dt1 = Open( "$Sample_data/Big Class.jmp" );
//Get the name of a column as a string
target_var = Column( dt1, "height" ) << Get Name;
//Open another table
dt2 = Open( "$Sample_data/Big Class Families.jmp" );
//Get a reference to the column in the second data table
field_data = Column( dt2, "height" );
//Sum the column using a reference to the column in a specific data table
ysum = Col sum( field_data );
Edited to use field_data in Col sum function.
Re: Sum of a column where column name is stored in a variableHi Jim,
Thanks, your script works fine. But I think I am having trouble due to another reason. I am defining target_var in a data table. Then I am trying to sum the column defined in target_var in another data table which also has the column name stored in target_var. Below is my code:
//Opening a data table
comp_data=open(path || comp_data_filename);
nc = ncols(comp_data);
target_var = column(nc); //Defining target_var
close(comp_data);
//Closing the data table
//Opening another data table
field_data=open(path || field_data_filename);
ysum = colsum(target_var); //This line does not work. I get an error saying "Column disappeared".
//JMP is not able to find the same column name in this new data table
Please let me know if this can be solved. Thanks!! 
Re: Sum of a column where column name is stored in a variableHere is a short script that uses what I believe uses your
target_var = column(6);
The script uses it in a calculation and in a Platform
names default to here(1);
dt=open("$SAMPLE_DATA/semiconductor capability.jmp");
target_var = column(6);
thesum=col sum(target_var);
show(thesum);
Distribution( Continuous Distribution( Column( target_var ) ) );
How are you attempting to use this in a Sum() function as you have indicated. Can you please provide some sample code of your efforts?
Re: Sum of a column where column name is stored in a variableHi pmroz,
Actually this also has the same problem that I told Jim about. Please let me know if I can take the column sum if my target_var stores the column name as an expression and not as a string. Thanks 
Re: Sum of a column where column name is stored in a variableHi Jim,
Actually target_var is not stored as a string. I have defined target_var as follows:
target_var = column(6);
The name of my 6th column is "diameter". So I think taget_var is storing the name of the column as an expression rather than a string. When I execute the following code, i do not get double quotes on diameter:
show(target_var);
The output of the above code is just target_var = :diameter. There are no qutations. So, let me know if I can sum the column corresponding to target_var now. Thanks 
Re: Sum of a column where column name is stored in a variableDid you want to use colsum instead of sum? This works:
target_var = "Diameter";
colsum(column(target_var));
Note that target_var is pointing to the string "Diameter", not the column :Diameter.
Re: Sum of a column where column name is stored in a variableIf I understand your current situation, your value of the variable Target_var is:
"target_var = :diameter"
To execute that literal string, you will need to run
Eval(Parse(Target_var));
The result of this will make the value of Target_var
:diamiter
You should then be able to run your code
sum(eval(target_var))