I have a Stata dataset containing variables:
B15. All variables with
A are gender and those with
B are the corresponding ages.
How can I combine all variables into just two variables,
B? So A would be
A1+A2+A3, ... ,
A15 and similarly for
The obvious answer seems to be
generate A = A1+A2+A3 ... generate B = B1+B2+B3 ...
or less painfully,
egen A = rowtotal(A*) egen B = rowtotal(B*)
assuming you have no other variables whose names begin with A or B. The obviousness of these answers makes me think I've not correctly understood what you hope to accomplish. Perhaps you should reveiew the following and pose your problem in the manner suggested.