Find a column whose name needs a string from another columnI am trying to use a value from a column named "Freq " and find another column . I get an error Invalid Row
The column I am looking for is available. The column Freq is numeric. Is that the issue?
For example the value in a row of the column Freq is 200 then I am looking for the value in IDynatTsense__200__65 .
Code:
HashFreqval = Column( "Freq" );
IDyn = Column( "IDynatTsense__"||HashFreqval[]|| "__65" );
Error:

Basic Data Analysis and ModelingRe: Find a column whose name needs a string from another columncolumn[] returns the value of the current row().
The default value of row() is 0. To access the value of row 1, just adjust the pointer via row()=1;
New Table( "test",
Add Rows( 1 ),
New Column( "Freq",
Character,
Set Values( {"200"} )
),
New Column( "IDynatTsense__200__65",
Set Values( [20] )
)
);
HashFreqval = Column( "Freq" );
row()=1;
IDyn = Column( "IDynatTsense__"||HashFreqval[]|| "__65" );Re: Find a column whose name needs a string from another columnError is caused by what hogi wrote, column()[] (same as column()[row()]) is looking for a value of current row which by default is 0 in JMP, which is invalid row number (you can read about this from Iterate on Rows in a Table (jmp.com)).
How are you utilizing this code? Most likely this isn't the whole code you are using? You are looking value from "Freq" but which row and are you maybe looping them? Are you trying to get a value from IDynatTsense__200__65 (which row?) or just the reference?
Re: Find a column whose name needs a string from another columnMaybe my question is not very clear. I am attaching a simple example
Depending on the value in the column HashFreq, I need to select data from either column Idyn_200_65 or Idyn_400_65.
Once I can get that data , I can use a formula to calculate further.
Names Default To Here( 1 );
dt1 = Open( "TestDataJunk.jmp" );
HashFreqval = Column( "HashFreq" );
IDyn = Column( "IDynatTsense__"||HashFreqval[]|| "__65" );
dt1 << New Column( "NewVal", Numeric, Continuous, Formula( IDyn[] ));
Thanks for your help!
Re: Find a column whose name needs a string from another columnIf your data is much more complicated and you don't need a formula, I would most likely just use For Each Row
Names Default To Here(1);
dt = Open("$DOWNLOADS/TestDataJunk.jmp");
dt << New Column("NewVal2", Numeric, Continuous);
For Each Row(dt,
val = Column(dt, "HashFreq")[Row()];
val_col = Eval Insert("Idyn_^val^_65");
Column(dt, "NewVal2")[Row()] = Column(dt, val_col)[Row()];
);