hi,
I need to use few columns to do calculation. the question I have is how to create new column and set value of each cell to 0 if same name column does not exist, it there is the column, do nothing. I tried below but it does not work the column already exist. can someone helps me out?
=Data Table( "FinalBiningTable" ) << Get Column Names();
(Column_list);
((contains(Column_list, "N(P, F)"))==0, Data Table( "FinalBiningTable" ) << New Column( "N(P, F)",numeric, ordinal );:Name("N(P, F)") << Set Each Value(0);, empty());
//dt = data table("FinalBiningTable"); // Uncomment for your table
dt = open( "$sample_data\Big Class.jmp" );
column_list = dt << Get Column Names(string);
if (!contains(Column_list, "N(P, F)"),
dt << New Column( "N(P, F)",numeric, ordinal, << Set Each Value(0));
);
//dt = data table("FinalBiningTable"); // Uncomment for your table
dt = open( "$sample_data\Big Class.jmp" );
column_list = dt << Get Column Names(string);
if (!contains(Column_list, "N(P, F)"),
dt << New Column( "N(P, F)",numeric, ordinal, << Set Each Value(0));
);
Thanks! PMroz
What is wrong in my lines of code?
The default data type for get column names is a list of columns (of column data type). When you add the string argument you get a list of column names as strings. You were trying to compare a column data type to a string.