The issue you are running into is that you were placing into the formula not a column name, like NPN1, but rather a literal string of "NPN". The Substitute function allows one to take the "NPN1" and substitute in :NPN1.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
Current Data Table();
lstNames = dt << Get Column Names( string, Numeric );
For( i = 1, i <= N Items( lstNames ), i++,
If( Contains( lstNames[i], "NP" ) == 1,
sigma = Col Std Dev( Column( dt, lstNames[i] ) );
Eval(
Substitute(
Expr(
special std dev = Col Std Dev(
If( (Col Mean( __col__ ) - 1.5 * sigma) <= __col__ | __col__ >= (Col Mean( __col__ ) + 1.5 * sigma),
.,
__col__
)
)
),
Expr( __col__ ), Parse( ":" || lstNames[i] )
)
);
Show( sigma, special std dev );
)
);
And here is another way to specify that the literal string is to be treated as a column name
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
Current Data Table();
lstNames = dt << Get Column Names( string, Numeric );
For( i = 1, i <= N Items( lstNames ), i++,
If( Contains( lstNames[i], "NP" ) == 1,
sigma = Col Std Dev( Column( dt, lstNames[i] ) );
special std dev = Col Std Dev(
If(
(Col Mean( As Column( lstNames[i] ) ) - 1.5 * sigma) <= As Column( lstNames[i] ) | As Column( lstNames[i] ) >= (
Col Mean( As Column( lstNames[i] ) ) + 1.5 * sigma),
.,
As Column( lstNames[i] )
)
);
);
Show( sigma, special std dev );
);
Jim