Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- Turning a continuous variable into a discrete variable

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Turning a continuous variable into a discrete variable

Jun 10, 2018 10:06 AM
(7343 views)

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Highlighted
##

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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Turning a continuous variable into a discrete variable

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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:

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

Learn it once, use it forever!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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**.

Learn it once, use it forever!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Turning a continuous variable into a discrete variable

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Turning a continuous variable into a discrete variable

You may find the Interactive Binning add-in useful.

-Jeff

Article Labels

There are no labels assigned to this post.