vendredi 16 juin 2017

SAS looking for a particular string in a variable and if it is present mark 1 in another variable?

I am looking to find that if I have a field with a long sentence like 'I like cooking, I like running, walking and hiking, I like reading'. How can I get SAS to look for 'I like running, walking and hiking' from the variable column and if it consists this value, then mark Activity variable as yes. If it contains 'I like cooking' then mark Cooking variable as yes and If it contains 'I like reading' then mark Study variable as yes.

Tablename DATA

id Hobbies Acitvity Study Cooking 1 'I like cooking, I like running, walking and hiking, I like reading' 2 'I like running, walking and hiking' 3 'I like running, walking and hiking, I like reading'

Aucun commentaire:

Enregistrer un commentaire