Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Looping question


From   "Carter Rees" <[email protected]>
To   <[email protected]>
Subject   st: Looping question
Date   Sat, 18 Mar 2006 10:34:07 -0500

Statalist,

Working with Stata 9.1, Windows XP.

I am working with a data set in which cases are students each of which has a
unique identifier aid.  Also, for each student I have a delinquency variable
(delinq) which is a count of the number of delinquent acts they have
committed over the past 12 months.  Each student has nominated up to 10
friends which are represented by the variable vector frnd1-frnd10.  The
values of frnd1-frnd10 are the aid's of each of the nominated friends.  What
I would like to do is create a variable vector fr1del-fr10del which takes on
the delinquency value for each of the nominated friends.

I have been exploring the reshape, foreach, and forvalues commands but have
not had much luck to date.

aid delinq frnd1 frnd2 frnd3 frnd4 frnd5 ...
99   2       66    77
88   3       77    99
77   5       55    44   99
66   2       88    99   44   77
55   6       44
44   8       66


Thank you.

Carter


*
*   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