Hello there,
I was struggling with the following problem in stata:
I have a string variable "bench" which represents city where a court hearing took place. I want to make a dummy variable for each of the cities which represents each of the bench string e.g. one dummy for "isl" one for "lar" etc. This I know, I can do by using:
tab bench, gen(city)
However, there are some typos in my string variable bench. For example, the same city Islamabad is sometimes coded as "isl", "isb" and "isd". Naturally, making dummy variable based on my old string will give me extra dummies on the same Islamabad city.
So, how can I rename the string so that I can have one dummy variable per city.
I tried:
if bench == "isd" | "isb" == 1 {
replace bench = "isl"
}
But this did not work. How should I proceed to solve this problem? Thank you in advance.
Kind Regards,
Sultan
I was struggling with the following problem in stata:
I have a string variable "bench" which represents city where a court hearing took place. I want to make a dummy variable for each of the cities which represents each of the bench string e.g. one dummy for "isl" one for "lar" etc. This I know, I can do by using:
tab bench, gen(city)
However, there are some typos in my string variable bench. For example, the same city Islamabad is sometimes coded as "isl", "isb" and "isd". Naturally, making dummy variable based on my old string will give me extra dummies on the same Islamabad city.
So, how can I rename the string so that I can have one dummy variable per city.
I tried:
if bench == "isd" | "isb" == 1 {
replace bench = "isl"
}
But this did not work. How should I proceed to solve this problem? Thank you in advance.
Kind Regards,
Sultan
Comment