JMP appears to be having an issue with using just the Column() function. However, the As Column() function corrects the issue.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Column( "Old", Character, Formula( If( :age >= 14, "Old", "Young" ) ) );
colnames = dt << get column names( numeric, string );
For( i = 1, i <= N Items( colnames ), i++,
Eval(
Substitute(
Expr(
New Column( Char( colnames[i] ) || " mean",
Numeric,
Formula( Col Mean( as Column( __colname__ ), :old ) )
);
New Column( Char( colnames[i] ) || " STD DEV",
Numeric,
Formula( Col Std Dev( as Column( __colname__ ) ) )
);
New Column( Char( colnames[i] ) || " CV%",
Numeric,
Format( "Percent", 2 ),
Formula( Col Std Dev( as Column( __colname__ ) ) / Col Mean( as Column( __colname__ ) ) )
);
),
Expr( __colname__ ), colnames[i]
)
)
);
Since you are using the Substitute() function, you could also remove the As Column() or Column() functions, and replace the __colname__ with the actual column reference of :theactualcolumnname. See below
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Column( "Old", Character, Formula( If( :age >= 14, "Old", "Young" ) ) );
colnames = dt << get column names( numeric, string );
For( i = 1, i <= N Items( colnames ), i++,
Eval(
Substitute(
Expr(
New Column( Char( colnames[i] ) || " mean",
Numeric,
Formula( Col Mean( __colname__ , :old ) )
);
New Column( Char( colnames[i] ) || " STD DEV",
Numeric,
Formula( Col Std Dev( __colname__ ) )
);
New Column( Char( colnames[i] ) || " CV%",
Numeric,
Format( "Percent", 2 ),
Formula( Col Std Dev( __colname__ ) / Col Mean( __colname__ ) )
);
),
Expr( __colname__ ), Parse( ":" || colnames[i] )
)
)
);
Jim