cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
View Original Published Thread

Column name as variables

shasha
Level I

Hi there,

I have a question related to the column name convention.

For example, I have a table contains the ages of students from several grades.

age_grade1age_grade2age_grade3age_grade4age_grade5age_grade6age_grade7

I like to define a parameter, so I can use "for" loop to do some data processing.

1: only select the non-empty rows.

Parameter = "age_grade1" ;

dtRaw << Select Where( Is Missing( Parameter ) );

however, it won't do anything.

2. select students age in some range.

Parameter = "age_grade1";

dtRaw = select where (Parameter > 7);

it is not working either.

Please help me figure this out. What is the right syntax for the column name?

Thanks,

Shasha

1 REPLY 1
pmroz
Super User


Re: Column name as variables

You need to supply a column reference in this context.  Also don't use parameter as a variable name - that's a JSL function.  If the word(s) turn blue in the editor then it means that it's a function.

This code works.  Note the use of as column for the column reference.

dtraw = current data table();

col_name = "age_grade1" ;

dtRaw << Select Where( Is Missing( as column(dtraw, col_name) ) );

dtRaw << select where (as column(dtraw, col_name) > 7);