The issue with your code is that you are not understanding the Formula element from the New Column function. You seem to be approaching the problem thinking that each segment within your line of script that has a function, such as Substr() or Left() needs to be told that it is a formula. Actually, the entire line of jsl:
If( Substr( :Column 9, 1, 2 ) == "CP", Left( :Column 9, 3 ), "" )
is what needs to be declared as the formula for the new column. Thus the New Column() function needs to be specified as:
dt << New Column( "Stage",
Character,
"Nominal",
Formula( If( Substr( :Column 9, 1, 2 ) == "CP", Left( :Column 9, 3 ), "" ) )
);
Jim