Stata s matrix language does contain commands such as matrix accum which can build a cross product matrix from. For cond a b c b is returned if a is true and c is returned otherwise. X0 interpreted literally says to load a copy of the dataset transpose.