cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Maerawlings
Level II

Regex Issure with Decimals and Whole Numbers

Hello!

 

Using JMP 16.2: I have a column with whole numbers and decimal numbers. I want to create a new column that flags the whole numbers (or the decimals). 

 

Column Name: Value

Column Inputs:

0

.5

3

3.768

10

etc.

 

I have tried several versions of the following Regex using a column formula:

Regex(Value,"\d+\,\d+", "Decimal")

Regex(Char(Value),"\d+\,\d+", "Decimal")

I have also tried parentheses and brackets throughout the second input.

 

I also have noticed, if there is a column with ONLY decimals and not whole numbers, the regex works...

 

Anyone have a useful trick to get this to work?

 

Thanks!

 

 

3 REPLIES 3
jthi
Super User

Re: Regex Issure with Decimals and Whole Numbers

Do you have a character column or some custom format? Which formats would you allow for decimals values? For example is ".1" valid decimal? And do you have to worry about something else besides those? You might be able to just use Contains(:Value, ".") and check if "." is found from the string

 

Edit:

Good place to test (and learn) regex: https://regex101.com/r/zBunSb/2

-Jarmo
Maerawlings
Level II

Re: Regex Issure with Decimals and Whole Numbers

Hello! The format for the NEW column is "Numeric" and the source column (Value) is also numeric. There are no characters in the source column.

 

".1" would not be valid, my mistake, they are marked as "0.1" for numbers <1.

 

I did try the contain and that is giving me a warning: Contains(:"Value"n,".") 

Error: argument is wrong type

 

(thanks for the regex site to test my ideas!)

Re: Regex Issure with Decimals and Whole Numbers

If your source and destination are Numeric columns, then you can use a Boolean expression in a formula in the destination data column

(:Value - Round( :Value, 0 )) == 0

Or

Modulo( :Value, 1 ) == 0

So your table looks like this:

whole.PNG

I used the Value Labels column property to display words instead of just 0 or 1.