cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
terapin
Level VI

JSL: Set Custom Format Data Column

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 ));

1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: JSL: Set Custom Format Data Column

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.

 

Try this:

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.

JMPScreenSnapz168.png

-Jeff

View solution in original post

4 REPLIES 4
Jeff_Perkinson
Community Manager Community Manager

Re: JSL: Set Custom Format Data Column

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.

 

Try this:

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.

JMPScreenSnapz168.png

-Jeff
terapin
Level VI

Re: JSL: Set Custom Format Data Column

Jeff,

 

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" )[2] - :Name( "Date & Time" )[1], Dif( :Name( "Date & Time" ), 1 ) / (:Name( "Date & Time" )[2] - :Name( "Date & Time" )[1]) - 1, 0 ) ); :Name( "Missing Dates?") << Format ( "Custom", Formula( If( :value == 0, ., :value ) ), 15 );
Jeff_Perkinson
Community Manager Community Manager

Re: JSL: Set Custom Format Data Column

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 );
-Jeff
terapin
Level VI

Re: JSL: Set Custom Format Data Column

Thanks Jeff, that certainly works.  It's interesting that the Copy Table Script command shows value with a : in front of it.