Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: computation across rows


From   Hewan Belay <hewan_belay@yahoo.com>
To   Stata List <statalist@hsphsun2.harvard.edu>
Subject   st: computation across rows
Date   Thu, 10 Feb 2011 12:17:09 -0800 (PST)

Dear Statalist,

I am trying to do something I expected to be very simple, but I'm not finding a 
straightforward way to do this. Essentially, I would like to do discrete 
computations across rows/observations (ie within variables). Here is an example 
of what I mean, consider this toy dataset (I hope the table is easily visible):

id       Y    Z    W
81       4    1    3
82       .     0    9
85      2     4    1
87      3     1     4
89      6     2    5

For the id #82, I want the variables Y and W to take on the value that results 
when adding their respective values for IDs #85 and 89. In the above toy 
example, that means that the missing value would become an 8, and the value of 9 
would change to 6. I definitely don't want to xpose or reshape my data, as I 
have several other operations I am doing on the data given its current 
structure. 


So generally speaking, my question is how to do computations across selected 
rows. I only have info on this with regard to computations X rows above or 
beyond the concerned row, that is using the operation [n+1], or when getting 
statistics for groups of rows using the -by- command.

Many thanks for any insights!
Hewan



      

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index