[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: using SAS-like arrays to create new variables
I am brand new to using STATA. Each observation in the data file I am using represents a male respondent. I am attempting to construct three new variables in STATA 9 using seven existing variables in the data set. Each of the seven variables indicates the current living situation of up to seven children the respondent fathered with a current spouse or partner and is coded 1=child lives in household, 2=child lives outside of household, and 3=child is dead or adopted. The first new variable I need to construct is to indicate the sum of all the 1's (total number of resident children ), the second new variable is to indicate the sum of all the 2's (total number of nonresident children), and the third new variable is to indicate the sum of all the 3's (total number of children in other situations) for each male respondent across the seven variables (for those who had children). It is unclear to me from the manuals how to use the "foreach" statement to generate these three n
ew variables. I am a SAS user, but previous threads on SAS-like arrays in STATA do not appear to address a situation quite like my question. Does anyone have recommendations on the syntax to use?
* For searches and help try: