cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Security Notice: CVE-2026-109618 and CVE-2026-109619

    JMP promptly initiated a review of its products, services, and relevant infrastructure for exposure to CVE-2026-109618 and CVE-2026-109619.

    Our assessment of JMP products has not identified exposure to these vulnerabilities. Where remediation was required within supporting environments, appropriate security updates and controls have been applied and validated.

    We have identified no evidence of successful exploitation or unauthorized access to JMP systems or customer information associated with these vulnerabilities.

    JMP continues to monitor the issue and relevant vendor guidance. No action is required by JMP customers at this time.

  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
David_Hanslian
Level II

Loop to set a normalization formula for several columns

Hi community,

I'm trying to write a JSL script to set a normalization formula with dynamic column reference. 

 

What's wrong here?
"Mean(M4_pop)" & "Std Dev(M4_pop)" are fix columns that are to be used for the normalization. 

 

dt = Current Data Table();

numCols = dt << Get Column Names( Numeric, "String" );

For( i = 1, i <= N Items( numCols ), i++,

     colName = numCols[i];  

    normColName = colName || "_norm";

    dt << New Column(

        normColName,

        Numeric,

        Continuous,

        Formula( (colName- :"Mean(M4_pop)"n) / :"Std Dev(M4_pop)"n)

    );

    );

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Loop to set a normalization formula for several columns

Hi David,

 

there might be prettier solutions but this is one way to make it work:

 

dt = Current Data Table();

numCols = dt << Get Column Names( Numeric, "String" );

For( i = 1, i <= N Items( numCols ), i++,

    colName = numCols[i];
     
    mean = "Mean(M4_pop)";
    
    std =  "Std Dev(M4_pop)";

    normColName = colName || "_norm";

    dt << New Column(

        normColName,

        Numeric,

        Continuous,

        Formula( (as column(colName)- as column (mean)) / as column(Std))

    );

    );
    

Cheers,

Jonas

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Loop to set a normalization formula for several columns

You will have to evaluate colName to the formula
Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute 

-Jarmo

Re: Loop to set a normalization formula for several columns

Hi David,

 

there might be prettier solutions but this is one way to make it work:

 

dt = Current Data Table();

numCols = dt << Get Column Names( Numeric, "String" );

For( i = 1, i <= N Items( numCols ), i++,

    colName = numCols[i];
     
    mean = "Mean(M4_pop)";
    
    std =  "Std Dev(M4_pop)";

    normColName = colName || "_norm";

    dt << New Column(

        normColName,

        Numeric,

        Continuous,

        Formula( (as column(colName)- as column (mean)) / as column(Std))

    );

    );
    

Cheers,

Jonas

David_Hanslian
Level II

Re: Loop to set a normalization formula for several columns

Hi Jonas,

 

thanks for your response. Small changes that led to sucess :) 

Recommended Articles