Hello @Stokes ,
Welcome to the JSL Community. The community should be able to help you address your problem. However, for your future posts , may I suggest a small thing, when you post code , kindly insert using one of the following options shown below. This will help format the code and make it easier for community users to understand your code and help answer your questions.
Now that we have gotten that out of the way , lets see how to address your problem:
If I understand your question correctly -
1. How to compare columns in a data table against any parameter ?
2. Why does a column reference ( Col = Column(dt,i); ) not directly replace a column name (:Col1) in a function call ?
I will try to address these questions as best as I can - so please let me know if I dont address anything in my response .
Clear Globals(); Clear Log(); // Open Sample Data dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" ); // Acquire Column Names ColNames = dt1 << Get Column Names("String"); // Define a searchword and look for it in column names DesiredColsPos1 = list(); DesiredColsPos2 = List(); KeyWord1 = "age"; for(i = 1 , i <= N Cols(dt1), i++, If(Contains(ColNames[i],KeyWord1), Insert Into(DesiredColsPos1,i); ); ); // Display Result Show(DesiredColsPos1); // Alternatively for(i = 1 , i <= N Cols(dt1), i++, Col = Column(dt1,i); // This gets a reference for the column Show(Col); ColName = Col << Get Name; If(Contains(ColName,KeyWord1), Insert Into(DesiredColsPos2,i); ); ); // Display Result Show(DesiredColsPos2);