Skip to content
Prev 77124 / 398502 Next

if() command

Hi everyone !

Could you please help me with this problem ?

I??ve trying to write a code that assign to a variable the content from 
another, but all I??ve got is a message error. For example:

if (age <=10) {group == 1}
else if (age > 10 & age <= 20) {group == 2}
else {group == 3}

Syntax error

Or

if (age <=10) {group == 1}
else (age > 10 & age <= 20) {group == 2}
else {group == 3}

Syntax error

I know that is possible to find the solution by ifelse command or even 
recode command, but I??d like to use this way, because I can add another 
variable as a new condition and I believe to expand the possibilites.

Thanks,
Mauricio