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

- JMP User Community
- :
- Discussions
- :
- How do I use JSL to categorize positive and negative values in the same column?

- 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

Jul 18, 2019 12:54 AM
(1574 views)

According to the data of the "weight" column in document "Arrhythmia" 、and the "criterion" file in the attachment, the "level" column is obtained.

Then, according to the "level" column and "class" column, the data of "V3 QRSTA" column are classified according to the following rules:

Row basis is "level", column basis is "class", and positive value and negative value of "V3 QRSTA" column are classified and summarized respectively.

The above operations can be easily completed with excel and its functions, but the speed is slow when the data volume is large.

If the amount of data is large, how to use JMP JSL should be completed more quickly.Thank you very much!

This problem is quite complicated. I made several pictures and uploaded 2 files.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

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

Here is an example of one way to do the processing to set the grade for each raw data row. I have it set to have an Example data table of 50,000, which on my 4 year olf Window's pc takes about 2 seconds to create the example data and then to set the grade for each row.

```
Names Default To Here( 1 );
// Create a sample standards table
dtStandard = New Table( "Standards",
Add Rows( 200 ),
New Column( "standards", formula( Random Integer( 93500, 1000000 ) ) )
);
dtStandard << run formulas;
dtStandard:standards << delete property( "formula" );
dtStandard << sort( by( :standards ), order( ascending ), replace table( 1 ) );
dtStandard << rerun formulas;
dtStandard << New Column( "grades", formula( Row() ) );
dtStandard:grades << delete property( "formula" );
// Create an example table
dt = New Table( "Example",
Add Rows( 50000 ),
New Column( "Raw Data", formula( Random Integer( 93500, 1000000 ) ) )
);
dt << run formulas;
dt:Raw Data << delete property( "formula" );
// Make sure the standards table has the same range as the example table
If( dtStandard:standards[1] > Col Min( dt:raw data ),
dtStandard:standards[1] = Col Min( dt:raw data )
);
If( dtStandard:standards[200] < Col Max( dt:raw data ),
dtStandard:standards[200] = Col Max( dt:raw data )
);
// Set the standard
// The code below is the actual code that performs the setting of the grade
// Create a column to hold the original row positions in the data table
dt << New Column( "OrigRow", formula( Row() ) );
dt:OrigRow << delete property( "formula" );
// Add the new grades column to the Example data
dt << New Column( "grade" );
// Sort the data in order of the raw data
dt << sort( by( :Raw Data ), order( ascending ), replace table( 1 ) );
For( i = 1, i <= N Rows( dt ), i++,
If( i == 1,
lkupRow = Max( dtStandard << get rows where( dtStandard:standards <= dt:Raw Data[i] ) )
);
While( dtStandard:standards[lkupRow] < dt:Raw Data[i], lkupRow = lkupRow + 1 );
dt:grade[i] = dtStandard:grades[lkupRow];
);
// Sort the data back to the original order
dt << sort( by( :OrigRow ), order( ascending ), replace table( 1 ) );
// Delete the origrow column
dt << delete columns( "OrigRow" );
```

Jim

22 REPLIES 22

Highlighted
##

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

Re: How do I use JSL to categorize positive and negative values in the same column?

dt = Open( "$SAMPLE_DATA/Arrhythmia.jmp" );

Highlighted
##

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

Re: How do I use JSL to categorize positive and negative values in the same column?

Created:
Jul 18, 2019 12:57 AM
| Last Modified: Jul 18, 2019 1:11 AM
(1570 views)
| Posted in reply to message from lwx228 07-18-2019

Highlighted
##

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

Re: How do I use JSL to categorize positive and negative values in the same column?

I know it's stupid, but it's the only way I can handle it.Thank you very much!

Highlighted
##

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

Re: How do I use JSL to categorize positive and negative values in the same column?

Solve the first step above all: how to divide "weight" column by the "criterion" in accessory a few grades.

Highlighted
##

See screenshot for standard: The operation of this step, I can only use the way of "IF". Excel has several functions that do this. How does JSL do this quickly?Thank you very much!

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

Re: How do I use JSL to categorize positive and negative values in the same column?

Highlighted
##

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

Re: How do I use JSL to categorize positive and negative values in the same column?

This can be handled easily in a JMP formula

```
If(weight<=30, 1
weight <= 40, 2,
weight <= 50, 3,
etc.
)
```

Jim

Highlighted
##

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

Re: How do I use JSL to categorize positive and negative values in the same column?

Thank Jim!

but If this grade classification reaches more than 100, such classification method code is more cumbersome.

but If this grade classification reaches more than 100, such classification method code is more cumbersome.

Highlighted
##

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

Re: How do I use JSL to categorize positive and negative values in the same column?

If you had the classification in a table as shown above, a script could easily create the expression for the necessary If() function. Or you could use the approach of lookup in such a table.

More than 100 classes? Would they be meaningful or useful? At this point you might want to just use the original continuous variable.

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: How do I use JSL to categorize positive and negative values in the same column?

Thank you for your time.

Article Labels

There are no labels assigned to this post.