creating a variable with multiple condition

creating a variable with multiple condition

by Eunjeong -
Number of replies: 3

Hi, I am working on my own dataset and ran into a question. 

I am trying to assign group# to my dataset to categorize them

I created a new variable but I wasn't sure if it's feasible to have multiple conditions.. 

for example..

if I want to assign people with disease condition and defibrillator...

--------------------

generate group=.

replace group=1 if ca=="history of cardiac amyloidosis" and device=="yes"

----------

clearly the second command didn't work.. is it possible assign mutiple conditions when generating a variable? 

appreciate your help!!

In reply to Eunjeong

Re: creating a variable with multiple condition

by Atul Kumar -

Try this:


generate group=.

replace group=1 if ca=="history of cardiac amyloidosis" & device=="yes"


In reply to Atul Kumar

Re: creating a variable with multiple condition

by Eunjeong -


generate group=.

replace group=1 if ca=="history of cardiac amyloidosis" & device=="yes"



it keeps saying type mismatch.. 

it does not recognize anything after "history of cardiac amyloidosis" as part of "if" command...


In reply to Eunjeong

Re: creating a variable with multiple condition

by Eunjeong -

Oh i used the numbers instead and it worked! 

I thought we could use them interchangeably.....


generate group=.

replace group=1 if ca ==1 & device ==1


thanks for the help!