Rana, please pay attention to the new variable that you just created, called -country_id-, and then using a different variable name when defining the condition, -country_code-. This was the typo I referred to.
Using -encode- turns your string variable country into a labelled, numeric variable (you've already made it and called it -country_id-) on Carlo's suggestion. The following code will select all countries that are not in the mentioned list, and then drop them, which with your data example, results in an empty dataset.
You will need to ensure that the countries are correctly selected.
Using -encode- turns your string variable country into a labelled, numeric variable (you've already made it and called it -country_id-) on Carlo's suggestion. The following code will select all countries that are not in the mentioned list, and then drop them, which with your data example, results in an empty dataset.
Code:
gen wanted=1 if !inlist(country_id, 20, 63, 179) drop if wanted
Comment