While I can manually Set Custom Format for a specific data column, I can't find the command that would let me do this in JSL.
Does anyone know the JSL command that would allow me to Set Custom Format using the following conditional statement? Thanks.
Column(var1) << Set Custom Format( If( :value == 0, ., :value ));
You can do that with the Format() message to the column, but it seems really risky.
You're not actually changing the zeros to missing. You're just displaying them as a missing. Platforms will still analyze the actual value.
dt=open("$SAMPLE_DATA\Big Class.jmp"); :height<< Format( "Custom", Formula( If( value == 59, ., value ) ), 5 ); dt<<new column("height2", Formula( :height ) ); dt<<Distribution( Continuous Distribution( Column( :height ) ) ); dt<<Select Where( :height == 59 );
BTW: I got the code for the Format() message by setting the custom format by hand and then examining the Table Script.
Thanks for replying to my question and sharing with me how you found the code for the Format() command. That will come in handy in the future.
I certainly understand the issue you raised about the data only being displayed as missing. That is exactly what I'm going for in this instance. I have a column that I use for determining when I have missing data records based on datetime. When looking over this column, I find it rather hard to "see" the rows where missing data exists, if any, due to all the zeros. That's why I'm displaying them as missing.
Interestingly, following the code example you provided for my data doesn't work like it does for Big Class. When I execute the following code for the attached data table, the column of interest (Missing Dates?) is set to ####### when the code is run. However, if I select Column Information | Set Custom Format | Ok | Ok, the column "Missing Dates?" is now updated properly with the specified custom format. If I rerun just the code that sets the proper custom format, I get the same ##### result. Weird. Am I doing something wrong or is this a possible bug?
Clear Log(); Names Default To Here( 1 );
dt = Current Data Table(); dt << Add Multiple Columns( "Missing Dates?", 1, before first, Numeric ); :Name( "Missing Dates?") << Formula( If( Dif( :Name( "Date & Time" ), 1 ) != :Name( "Date & Time" ) - :Name( "Date & Time" ), Dif( :Name( "Date & Time" ), 1 ) / (:Name( "Date & Time" ) - :Name( "Date & Time" )) - 1, 0 ) ); :Name( "Missing Dates?") << Format ( "Custom", Formula( If( :value == 0, ., :value ) ), 15 );
It seems to be the colons that you put in front of value in the Format().
If you remove them it works as expected.
:Name( "Missing Dates?" ) << Format( "Custom", Formula( If( value == 0, ., value ) ), 15 );