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

question on right function

Trying to use Right function as below in my jsl code

dt << New Column("ORIG_MARK",Character,Nominal,Formula(Right(:result,(Contains(:result,"_",3)))));

The result of this statement is as below,but I intend to eliminate the "_" from every row in the ORIG_MARK column.How can I modify the above statement to accomplish this?

resultORIG_MARK
ORIG_MARK_A_A
ORIG_MARK_B_B
ORIG_MARK_C_C
ORIG_MARK_D_D
ORIG_MARK_E_E
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: question on right function

Right(str, n) will return you right n characters of str. Contains(str, pattern, n) will return you first index of pattern in str starting from n. If you want to get string after last "_" I would use Word() or Substitute() to remove "ORIG_MARK_". If you want to use Right(), you will have to calculate the length of string you want get for example by using combination of Length() and Contains().

 

Here is one option using Word():

Word(-1, :result, "_")

 

See Scripting Index for examples.

-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: question on right function

Right(str, n) will return you right n characters of str. Contains(str, pattern, n) will return you first index of pattern in str starting from n. If you want to get string after last "_" I would use Word() or Substitute() to remove "ORIG_MARK_". If you want to use Right(), you will have to calculate the length of string you want get for example by using combination of Length() and Contains().

 

Here is one option using Word():

Word(-1, :result, "_")

 

See Scripting Index for examples.

-Jarmo