Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: using SAS-like arrays to create new variables


From   "Lamb, Kathy" <[email protected]>
To   <[email protected]>
Subject   st: using SAS-like arrays to create new variables
Date   Sat, 24 Sep 2005 11:44:40 -0500

Greetings,

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?

Thank you,

Kathy Lamb

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index