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
saitcopuroglu
Level IV

How to convert char to num

Dear All,

I have the data as follows and whatever I tried I can't make the new formula column a numeric one.

Could someone help please?

many thanks in advance

10199_Screen Shot 2015-10-15 at 14.35.29.png

26 REPLIES 26
ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to convert char to num

To get a slightly simpler formula, use multiple arguments in Substitute().

For example:

Substitute(:Comment, "!", " ", "+", " ", "%", " ", "_", " ", "-", " ", "?", " ");

saitcopuroglu
Level IV

Re: How to convert char to num

Thank you MS,

Thank you jvillaumie,

Both work very well !

I am continuously checking the tutorials, books, help, webcasts but sometimes when it comes to action some very simple thing is missing. In this example I knew the Substitute function but did not know it could be surrounded by another Substitute and another and another and by collapse whitespace and lowercase functions...

Many many thanks again, it saved me 8 minutes for each day of my rest life...

saitcopuroglu
Level IV

Re: How to convert char to num

Dear all,

again to same topic this time I can not create a formula column which divides the first number by second number (4/5, 44./5, 7.3/10...etc...)

Substraction does not work cos no equal lenght, Substitute is not a way to go Words can not seperate the characters....

many thanks!

10240_Screen Shot 2015-10-22 at 14.46.21.png

ian_jmp
Level X

Re: How to convert char to num

I have not read the whole thread. But perhaps this is close (if you can depend on the 'divide' delimiter):

New Table( "Convert Char Fraction",

Add Rows( 4 ),

New Column( "Char Fraction",

Character,

"Nominal",

Set Values( {"4 / 5", "3/2", "27/     26", "122       /37.6"} )

),

New Column( "Result",

Numeric,

"Continuous",

Format( "Fixed Dec", 12, 3 ),

Formula(

Num( Trim( Word( 1, :Char Fraction, "/" ) ) ) /

Num( Trim( Word( 2, :Char Fraction, "/" ) ) )

)

)

);

DaveLee
Level IV

Re: How to convert char to num

Saitcopuroglu,

You should be able to use the following formula:

Num(Word(1,:Score, "/"))/Num(Word(1,:Score, "/"))

Dave

saitcopuroglu
Level IV

Re: How to convert char to num

Many thanks, both work.

msharp
Super User (Alumni)

Re: How to convert char to num

Given all the questions, and the length of this post.  I'm just going to let you know, it'd be worth the hour of your time to study regular expressions.  Regular expressions are a very common programming technique that is universal and can be found in almost all programming languages.  Regular expressions can do everything above and more.

The JSL Scripting guide has a very good subsection that should cover all you need to know about the regex() function.  And there are plenty of YouTube videos that go in depth as well.