cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
ValarieSimmons
Level III

Binning Help?

Hi,

I would like to create binned columns by scripting instead of doing it manually (Cols -> Utilities -> Make Binning Formula) but I am not able to figure out how to do so.

1) May I know is there a way to script "Make Binning Formula"? Is yes, can anyone advise me on how to do this?

2) Another question that I would like to ask is, while doing "Make Binning Formula" manually, every selected parameter has their own unique width (refer to the diagram below). How can I retrieve the width value for different parameters? I am currently using "Cholesterol" data from the sample data library as a reference.

11352_pastedImage_0.png

I would greatly appreciate any help from anyone of you out there . Thank you.

Regards,

Val

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Binning Help?

Val,

The Make Binning Formula creates a new column, that sets it's Value Labels.  If you select to "Use Range Labels" the new column's value labels will look something like:

{18 <= "18 — 26" < 26, 26 <= "26 — 34" < 34, 34 <= "34 — 42" < 42, 42 <=

       "42 — 50" < 50, 50 <= "50 — 58" < 58, 58 <= "58 — 66" < 66, 66 <= "66 — 74" < 74,

       74 <= "74 — 82" < 82, 82 <= "82 — 90" < 90, 90 <= "90 — 98" < 98, 98 <= 

       "98 — 106" < 106, 106 <= "106 — 114" < 114, 114 <= "114 — 122" < 122, 122 <=

       "122 — 130" < 130, 130 <= "130 — 138" < 138, 138 <= "138 — 146" < 146, 146 <=

       "146 — 154" < 154, 154 <= "154 — 162" < 162, 162 <= "162 — 170" < 170, 170 <=

       "170 — 178" < 178, 178 <= "178 — 186" < 186, 186 <= "186 — 194" < 194, 194 <=

       "194 — 202" < 202}

The list can then be parsed and the lower and upper boundaries can be extracted.

Here is a script that I used against my own data table that the Make Binning Formula had created a column called NPN1 Binning

 

Names Default To Here( 1 );

dt = Current Data Table();

 

// Get the Value Labels, and parse them into a list

TheLabels = Char( dt:npn1 binned << get property( "Value Labels" ) ); 

thelabels = Substr( thelabels, 14, Length( thelabels ) - 14 ); 

thelabels = Parse( thelabels );

   

// Create a new table to hold the values 

dtbnd = New Table( "Boundries", New Column( "Lower Boundry" ), New Column( "Upper Boundry" ) ); 

dtbnd << add rows( N Items( TheLabels ) );

   

// Pass through the list and strip off the upper and lower boundaries 

For( i = 1, i <= N Rows( dtbnd ), i++, 

       dtbnd:Lower Boundry[i] = Num( Word( 1, Char( TheLabels[i] ), "<" ) ); 

       dtbnd:Upper Boundry[i] = Num( Word( 3, Char( TheLabels[i] ), "<" ) ); 

);

 

Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: Binning Help?

I think the "Interactive Binning" JMP addin that Jeff Perkinson wrote is either an answer to your issue, or at least a good starting point.  The addin is available under File Exchange.

Jim
ValarieSimmons
Level III

Re: Binning Help?

Hi Jim, thanks for the info. I looked into the "Interactive Binning" JMP add in & it's really interesting. However it also seem to be quite manual. Is there any way to get the width for each selected column (as shown in the image above) directly from the pop out window after clicking on "Make Binning Formula"?

Thanks,

Val

txnelson
Super User

Re: Binning Help?

Val,

The Make Binning Formula creates a new column, that sets it's Value Labels.  If you select to "Use Range Labels" the new column's value labels will look something like:

{18 <= "18 — 26" < 26, 26 <= "26 — 34" < 34, 34 <= "34 — 42" < 42, 42 <=

       "42 — 50" < 50, 50 <= "50 — 58" < 58, 58 <= "58 — 66" < 66, 66 <= "66 — 74" < 74,

       74 <= "74 — 82" < 82, 82 <= "82 — 90" < 90, 90 <= "90 — 98" < 98, 98 <= 

       "98 — 106" < 106, 106 <= "106 — 114" < 114, 114 <= "114 — 122" < 122, 122 <=

       "122 — 130" < 130, 130 <= "130 — 138" < 138, 138 <= "138 — 146" < 146, 146 <=

       "146 — 154" < 154, 154 <= "154 — 162" < 162, 162 <= "162 — 170" < 170, 170 <=

       "170 — 178" < 178, 178 <= "178 — 186" < 186, 186 <= "186 — 194" < 194, 194 <=

       "194 — 202" < 202}

The list can then be parsed and the lower and upper boundaries can be extracted.

Here is a script that I used against my own data table that the Make Binning Formula had created a column called NPN1 Binning

 

Names Default To Here( 1 );

dt = Current Data Table();

 

// Get the Value Labels, and parse them into a list

TheLabels = Char( dt:npn1 binned << get property( "Value Labels" ) ); 

thelabels = Substr( thelabels, 14, Length( thelabels ) - 14 ); 

thelabels = Parse( thelabels );

   

// Create a new table to hold the values 

dtbnd = New Table( "Boundries", New Column( "Lower Boundry" ), New Column( "Upper Boundry" ) ); 

dtbnd << add rows( N Items( TheLabels ) );

   

// Pass through the list and strip off the upper and lower boundaries 

For( i = 1, i <= N Rows( dtbnd ), i++, 

       dtbnd:Lower Boundry[i] = Num( Word( 1, Char( TheLabels[i] ), "<" ) ); 

       dtbnd:Upper Boundry[i] = Num( Word( 3, Char( TheLabels[i] ), "<" ) ); 

);

 

Jim
DaveLee
Level IV

Re: Binning Help?

There's an option to automatically create binned columns from continuous data.  It's under Cols>Utilities>Make Binning Formula.  It's very straightforward and provide many options that can then be used to create a new Binned column containing a formula matching your inputs and choices.  From here you could easily create a modal window that pops up an prompts you through the next instance. 

Jeff_Perkinson
Community Manager Community Manager

Re: Binning Help?

yihjiuntham0​, perhaps it will help us if you describe more clearly what you want to do.

Are you looking for a way to give the user of your script access to the Make Binning Formula window but maintain control after they are done?

Or perhaps, you are looking for a way to bin your continuous variables through JSL in a way that's similar to the result you get from Make Binning Formula.

Understanding your end goal will give us a better idea of how to point you in that direction.

-Jeff

-Jeff