Re: Error in loop to standarize numeric columnsWhen you specify a formula value, it will not do any evaluation of the JSL for the formula. Rather, it will just move the code into the formula. So, what is being placed into the formula is " Col Standardize( :numericColNames[i] )", not, "Col Standardize( :YourColumnName )". So when the formula is executed, it will look for the value of "i", which by the time it executes, it has already moved beyone your subscript range for Colnames. So what needs to be done is to place the exact JSL syntax for the formula, into the formula.
Names Default To Here( 1 );
dt = Current Data Table();
numericColNames = dt << get column names( string, numeric );
For( i = 1, i <= N Items( numericColNames ), i++,
Eval(
Substitute(
Expr(
New Column( Char( numericColNames[i] ) || "_Stand",
Numeric,
Continuous,
Formula( Col Standardize( __col__ ) )
)
),
Expr( __col__ ), Parse( ":" || numericColNames[i] )
)
)
);Error in loop to standarize numeric columnsHi. I have written a script to create new numerical columns from the formula to standardize but I get an error when evaluating the formula. What do I do wrong?
Thank you.
The script:
Names Default To Here( 1 );
dt = Current Data Table();
numericColNames = dt << get column names( string, numeric );
For( i = 1, i <= N Items( numericColNames ), i++,
New Column( Char( numericColNames[i] ) || "_Stand",
Numeric,
Continuous,
Formula( Col Standardize( :numericColNames[i] ) ) )
);
The error:
Name Unresolved: numericColNames 1 times At rows: {1} Operation: numericColNames, :numericColNames
Re: Error in loop to standarize numeric columnsDear Sir, I have a small table to try. It consists of a column with names of municipalities a column (1900) with integer values corresponding to the population in 1900 and another column expressed in percentages. When I try the scritp I find that, although the instruction "numericColNames = dt << get column names( string, numeric );" recognizes the col 1900 and "Percentage Canvi" as numerics when creating the two new columns, the one corresponding to 1900 leaves it with missing values.
Re: Error in loop to standarize numeric columnsA column name like 1900 can confuse JMP, because it may not know if it should treat it as a number or a column name. So one needs to specifically indicate that it is a column name by using the :Name() function...see the reworked script below
Names Default To Here( 1 );
dt = Current Data Table();
numericColNames = dt << get column names( string, numeric );
numericColNames = {"1900"}
For( i = 1, i <= N Items( numericColNames ), i++,
Eval(
Substitute(
Expr(
New Column( Char( numericColNames[i] ) || "_Stand",
Numeric,
Continuous,
Formula( Col Standardize( __col__ ) )
)
),
Expr( __col__ ), Parse( ":Name(\!"" || numericColNames[i] || "\!")" )
)
)
);Re: Error in loop to standarize numeric columnsSir, you seem to have an answer for everything. Thanks again for your contribution!