| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Looping across variables in variable columns
Thanks for the answer. We illustrate the problem with a short example.
We aim to test that parents economic performance being good, denoted (1) or bad, denoted (0) when children are ages 16 years and 17years may influence the children career behaviour even much later in life.
We have the information on the parental economic perfomance for a period of years, 1970 to 1972 in this example. We also know the years when the children were 16yrs and 17yrs which may, may-not or only partially overlap with the years of parental economic perfomance which we have available.
For years when the parental influence is not available, we assume the influence was bad i.e. value zero in the example.
The problem is to get a stata loop to compute the total parental influence for each child.
In the example, this total would be 2 for Mark, 1 for Paul and 0 for John.
Child Par. Inf.1970 Par. Inf.1971 Par.Inf. 1972 Yr. 16yrs Yr.17yrs Total par.Inf.
Mark 1 1 1 1970 1971 ?
Paul 0 1 0 1971 1972 ?
John 1 1 0 1972 1973 ?
________________________________
From: [email protected] on behalf of Maarten Buis
Sent: Thu 26/04/2007 10:39
To: [email protected]
Subject: st: RE: Looping across variables in variable columns
Somehow there should be information in your dataset about which columns should be added. Ways of solving this problem depends on how that information is stored, and as you didn't tell us, there is not much we can do to help you. So how do you know which columns to add?
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Mungai, Edward
Sent: donderdag 26 april 2007 4:28
To: [email protected]
Subject: st: Looping across variables in variable columns
I have seen discussions on looping across an unknown number of columns which can be solved by -reshape-
My question is how to sum across columns where the number of columns varies from one observation to the next. i.e. I may need to sum columns 2 to 5 for the first observation but from columns 4 to 11 for the second observation. In all cases the summation is done across a set of adjacent columns.
I have tried to use -rowcount-, and the looping functions but as far as I can tell all sum across a fixed number of columns from one observation to the next. But there is something good also; the information on the column to begin and the column to end the summation for each observation is contained in two adjacent column which are the same for all the observations.
Feedback is highly appreciated upfront.
Edward.
This message has been scanned for viruses by TRENDMICRO,
an IESE technology affiliate company and global leader in antivirus and content security software.
*
* 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/
*
* 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/
*
* 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/