Hello all,

I am trying to create a variable that combines the school district identifiers listed below (I actually have to combine over 50 of these but I only included a couple for the sake of clarity). If an individual lives in the ABC school district, for instance, ABC would be equal to 1 and every other distirct variable would be missing. The labor-intensive way I would envision doing this looks like this:


PHP Code:
gen school_district_str "ABC" if ABC== 1
replace school_district_str 
"Acton-Laguna Dulce" if Acton_Laguna_Dulce== 1
replace school_district_str 
"Antelope" if Antelope== 1
replace school_district_str 
"Alhambra" if Alhambra== 1
replace school_district_str 
"Arcadia" if Arcadia== 1
replace school_district_str 
"Baldwin" if Baldwin == 
However, I am sure there must be an easier way to complete this task without writing 50+ lines of codes. I would appreciate any insights on this.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(ABC Acton_Laguna_Dulce Antelope Alhambra Arcadia Baldwin)
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . 1 . .
. . 1 . . .
. . 1 . . .
. . . . . .
. . . . . .
. . . . . .
. . 1 . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . 1
1 . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
1 . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . 1 . .
. . 1 . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . 1 .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . 1 . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . 1 . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . 1 .
. . . . . .
. . . . . .
. . . . . .
end