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

- JMP User Community
- :
- Discussions
- :
- How do I check that a column contains only integers?

- 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

Apr 10, 2020 6:08 AM
(960 views)

Hello,

I need to check that a column contains only integers before running the rest of my script but I don't know how to do that. Ideally I would like to be able to identify precisely the rows with decimal values.

Thanks in advance for your help!

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

See the last line.

```
Names Default to Here( 1 );
// generate test case with a mix of 90% integers and 10% non-integers
data = J( 30, 1,
If( Random Uniform() < 0.1,
Random Normal(),
Random Integer( -6, 6 )
);
);
// check results
Show( data );
// make a data table example
dt = New Table( "Test Cases",
New Column( "Data", Numeric, Continuous,
Values( data )
)
);
// now the solution
nonIntegersHere = dt << Get Rows Where( Modulo( :Data, 1 ) );
```

Learn it once, use it forever!

2 REPLIES 2

Highlighted

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

See the last line.

```
Names Default to Here( 1 );
// generate test case with a mix of 90% integers and 10% non-integers
data = J( 30, 1,
If( Random Uniform() < 0.1,
Random Normal(),
Random Integer( -6, 6 )
);
);
// check results
Show( data );
// make a data table example
dt = New Table( "Test Cases",
New Column( "Data", Numeric, Continuous,
Values( data )
)
);
// now the solution
nonIntegersHere = dt << Get Rows Where( Modulo( :Data, 1 ) );
```

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 check that a column contains only integers?

What a beautiful solution!! Thanks @markbailey

Article Labels

There are no labels assigned to this post.