Hi,

I'd like to recode some variables so if a source contains a certain text I'd like to use a number for it.

Example:

Source

id1: Dog, Cat, Mouse

id2: Dog

id3: Dog, Cat

id4: Dog, Mouse

New variable 1:

If source contains Dog use 1

Then with this all the ids would use 1.

Right now I can only see the Equal to operator but that'll only work for id2.

I assume with a function it's doable, but I'm not so familiar with functions. Any ideas?

Thanks!

## Transformed variable - if source contains

### Re: Transformed variable - if source contains

hmm,

we've not encountered this sort of use case before. perhaps we need to consider it.

you'll need to use computed variables for this:

IF(CONTAINS('Dog', variableName), 1, IF(CONTAINS('Cat', variableName), 2, ... ))

jonathon

we've not encountered this sort of use case before. perhaps we need to consider it.

you'll need to use computed variables for this:

IF(CONTAINS('Dog', variableName), 1, IF(CONTAINS('Cat', variableName), 2, ... ))

jonathon

### Re: Transformed variable - if source contains

Thanks jonathon!

Mhmm, maybe I'm doing something wrong, but it doesn't seem to work. i use Version 1.0.8.0 on a MacOS Catalina.

https://i.imgur.com/Mq3Do56.png

Mhmm, maybe I'm doing something wrong, but it doesn't seem to work. i use Version 1.0.8.0 on a MacOS Catalina.

https://i.imgur.com/Mq3Do56.png

### Re: Transformed variable - if source contains

oh yeah, you'll need a more recent version.

jonathon

jonathon

### Re: Transformed variable - if source contains

Pefect, thank you so much!

### Re: Transformed variable - if source contains

Hi Jonathon, how many if can I concatenate in the same expression?jonathon wrote:hmm,

we've not encountered this sort of use case before. perhaps we need to consider it.

you'll need to use computed variables for this:

IF(CONTAINS('Dog', variableName), 1, IF(CONTAINS('Cat', variableName), 2, ... ))

jonathon

### Re: Transformed variable - if source contains

i don't think there's a limit

jonathon

jonathon

### Re: Transformed variable - if source contains

I've just installed version 2.3.21 and come across the same issue. I'm trying to transform job titles into whether they are technical or not. I'd just switched to using COMPUTE but I thought I'd Google before going any further.