cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
lala
Level VII

How do keep the value calculated by the formula to only two significant digits after the decimal point?

For example, the actual data for a column calculated like this is many digits.How can  directly compute something like the last column?

Thanks!

2023-03-09_10-06-12.png

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Column( "A" );
Column( "A" ) << Formula( Round( height /weight, 2 ) );
dt << run formulas;
Column( "A" ) << deleteFormula;
dt << run formulas;
d2 = dt << Summary( Group( age ), Max( A ), Freq( "ꗠ" ), Weight( "ꗠ" ), Link to original data table( 0 ) );
Column( d2, 3 ) << Format( "Fixed Dec", 20, 20 );
3 REPLIES 3
lala
Level VII

Re: How do keep the value calculated by the formula to only two significant digits after the decimal point?

I ended up saving table d2 in the actual data, which is huge.
SDF1
Super User

Re: How do keep the value calculated by the formula to only two significant digits after the decimal point?

Hi @lala ,

 

  I believe you can achieve that you're after with fewer steps in JSL. Below is a code that formats the new formula column with 2 decimal places. In the command Format("Fixed Dec", w, n), the first number "w" is the width of the field and the second number "n" is the number of digits after the decimal to keep. Not that I did not do the rounding in this example for the formula.

 

  In your JSL, you are setting both the width and number of digits after the decimal to 20, so this is why you get the output you see.

Names Default to Here (1);

dt = Open("$Sample_data/Big Class.jmp");
New Column("A", Formula(:height/:weight));
dt:A<<Format("Fixed Dec", 6, 2);

Hope this helps!,

DS

lala
Level VII

Re: How do keep the value calculated by the formula to only two significant digits after the decimal point?

2023-03-10_7-14-48.png

This method is not effective.Thank you for your help!