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
MathStatChem
Level VI

How can I use recode to prepend a character string to each value?

The situation is that I have a column of sequential values "A", "B", "C", ...  and I want to transform them to "Label A", "Label B", "Label C", ...

3-1-2019 2-12-35 PM.jpg

I know how to do this with a column formula or with JSL, but I was wondering if this is possible with Recode?  Perhaps with using a regular expression?  Any ideas on how to do this with Recode?

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How can I use recode to prepend a character string to each value?

There is an option in recode under the red triangle menu called "Replace String...". Check the box for regular expression. The regular expression for the position before the first charcter in a string is the ^ (caret). Place ^ in the search text box. Type Label into the replacement text box with a space after the word Label. Click okay and apply the recode. Replace String.PNG

 

-Olivia

View solution in original post

5 REPLIES 5

Re: How can I use recode to prepend a character string to each value?

The Recode command works with the values in a column, not across column headers.

Re: How can I use recode to prepend a character string to each value?

There is an option in recode under the red triangle menu called "Replace String...". Check the box for regular expression. The regular expression for the position before the first charcter in a string is the ^ (caret). Place ^ in the search text box. Type Label into the replacement text box with a space after the word Label. Click okay and apply the recode. Replace String.PNG

 

-Olivia

MathStatChem
Level VI

Re: How can I use recode to prepend a character string to each value?

Thanks! That's the answer I was looking for.  

DanielPais
Level I

Re: How can I use recode to prepend a character string to each value?

That's amazing, thanks!

One question, where can I access the "list of commands"? For instance, ^ is the position before the first character; * is the ...

 

I have a specific question, because I have text like this: "_S14", "_S15", "_S89"... And I would like to delete every "_SXX". Any suggestion?

 

Thanks,

 

 

Re: How can I use recode to prepend a character string to each value?

If the _SXX is at the end of the string, you can use in Recode the "extract Segment" option to extract the last part. 

If you want to use RegEx as in the example above, there are many RegEx guides available with an overview of all options. This is not JMP specific but RegEx related and therefore just search for Regular Expression guide and you'll have all what you need

/****NeverStopLearning****/