cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
dannyfinn11
Level III

Turning a continuous variable into a discrete variable

Hi all - was wondering if someone could give me a few pointers on a problem I'm struggling with. I would like to create a dummy variable using a range of values based on a continuous variable. 

I would like to take a set of values and place them in nominal "buckets" if you will.

For example the data is

12

45

11

13

I want take those values and id when range they fall into. So 1- 12, 13-20, etc. Any ideas??

9 REPLIES 9
txnelson
Super User

Re: Turning a continuous variable into a discrete variable

select the column you are interested in, and then go to 

     Cols==>Recode

and create a new column that has the values binned into new groups

Jim
dannyfinn11
Level III

Re: Turning a continuous variable into a discrete variable

done. But what about large datasets? The one I was working on was only 450 rows. If I have a dataset with 29K rows, can I use a formula to go through and recode everything?

txnelson
Super User

Re: Turning a continuous variable into a discrete variable

1. Yes you can use a formula.  Here is one version that you could use

If( Row() == 1,
	min = Col Min( :height );
	incr = (Col Max( :height ) - Col Min( :height )) / 9;
);
Floor( (:height - min) / incr ) + 1;

It uses the Big Class sample data table.  Just change the variable :Height out for the column you are calculating against.

2. But the number of rows does not affect the Recode.  Only the number of unique values within those rows.

Jim

Re: Turning a continuous variable into a discrete variable

I think that Jim already answered your question, but I wanted to expand a bit on the answer. The If() function in a formula or script is very versatile. Here is an example of what you want to do (bin data) from our JMP Software: Introduction to the JMP Scripting Language:

Capture.PNG

It compares the numeric value in Age with the cutoffs and returns a character string in the new column, Stage.

JSpear
Level I

Re: Turning a continuous variable into a discrete variable

I tried to follow this example using a column formula.  I get no error but the column is blank.

 

JSpear_0-1594513738165.png

 

Craige_Hales
Super User

Re: Turning a continuous variable into a discrete variable

if "Pilot A", etc, is a string, it needs quotation marks. There might be a message in the log about an undefined variable.

Craige

Re: Turning a continuous variable into a discrete variable

I forgot to mention that if you are not otherwise scripting, you can interactively create a new data column with the bins: select the data column with the continuous values and then select Cols > Utilities > Make Binning Formula.

dannyfinn11
Level III

Re: Turning a continuous variable into a discrete variable

YES!! This is what I needed :-) Thank you!!

Jeff_Perkinson
Community Manager Community Manager

Re: Turning a continuous variable into a discrete variable

You may find the Interactive Binning add-in useful.

-Jeff