Given the following dataset and commands:
sysuse auto, clear
generate x = .
replace x = 5 if price == 4099
replace x = 5 if price == 4749
I want to generate a new variable x that is equal to 5 if price belongs to a list of values.
The following command generates no new values of x and is incorrect:
replace x = 5 if price == 4099 & price == 4749
I need a simpler one-line method that does not involve replacing x the way I did it in the code above, which works, but is tedious and inelegant.