I want to create a binary variable which takes a value if a condition is met.
Say I want do the following
my command is as below
or
However, I get the error "expression too long" for both commands
But when I reduce the number of countries in the list it works. Is there a command that would handle this condition when there are many matching criteria?
Say I want do the following
Code:
gen OilExp = 1 if Country isanyoffollowing("Algeria","Bahrain","Iran","Iraq" ,"Kuwait","Oman", "Qatar","Saudi Arabia","Syria","United Arab Emirates")
Code:
gen OilExp = cond(inlist(Country, "Algeria","Bahrain","Iran","Iraq","Kuwait","Om an", "Qatar","Saudi Arabia","Syria","United Arab Emirates"), 1, 0)
Code:
gen OilExp = 1 if inlist(Country, "Algeria","Bahrain","Iran","Iraq","Kuwait","Om an", "Qatar","Saudi Arabia","Syria","United Arab Emirates") replace OilExp = 0 if OilExp == .
But when I reduce the number of countries in the list it works. Is there a command that would handle this condition when there are many matching criteria?
Comment