#delimit ; use ; foreach x of numlist 1 3 4 5 {; forvalues y=1/80 {; sort g`x'v16; by g`x'v16: egen t`x'_`y' = mode(m`y'); }; gen str80 stripe`x'=""; foreach y of varlist t`x'_1-t`x'_80 {; replace stripe`x' = stripe`x' + "A" if `y'==1; replace stripe`x' = stripe`x' + "B" if `y'==2; replace stripe`x' = stripe`x' + "C" if `y'==3; replace stripe`x' = stripe`x' + "D" if `y'==4; replace stripe`x' = stripe`x' + "E" if `y'==5; replace stripe`x' = stripe`x' + "F" if `y'==6; replace stripe`x' = stripe`x' + "G" if `y'==7; replace stripe`x' = stripe`x' + "H" if `y'==8; replace stripe`x' = stripe`x' + "." if `y'==.; }; };