Hi everyone,
I am trying to create a dummy variable with an OR condition.
I have the following variable:
company_location_id_1
1
5
3
6
2
etc
I need the dummy to be equal 1 if location is 1 or 2.
I tried:
generate Silicon_Valley = 1 if company_location_id_1 == company_location_id_1 == 1 | company_location_id_1 ==2 |
I also tried:
generate Silicon_Valley = 1 if company_location_id_1 == (1|2)
But in both cases all observations get a value of 1, while I need everything else to be 0.
Thank you in advance,
Cristiano
I am trying to create a dummy variable with an OR condition.
I have the following variable:
company_location_id_1
1
5
3
6
2
etc
I need the dummy to be equal 1 if location is 1 or 2.
I tried:
generate Silicon_Valley = 1 if company_location_id_1 == company_location_id_1 == 1 | company_location_id_1 ==2 |
I also tried:
generate Silicon_Valley = 1 if company_location_id_1 == (1|2)
But in both cases all observations get a value of 1, while I need everything else to be 0.
Thank you in advance,
Cristiano
Comment