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: data management question


From   Caroline Wilson <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: data management question
Date   Wed, 18 Sep 2013 21:57:37 +0000

Hello,

 

I’m wondering if someone can help with a data management
question. 

 

I’m trying to create a variable called “mean”, which, for a
given pat_ID, would be calculated by taking the mean of every other value of “Md_T”
in the same phy_ID EXCEPT for the current row. 


 

So, for example, in the below dataset:

 

For pat_ID = 2, the corresponding phy_ID is 100. Therefore,
I would like value of the variable “mean” for pat_ID=2 to be the mean of all
the other values of “Md_T”  for phys_ID OTHER
THAN the value when pat_ID = 2. 

 

For pat_ID = 1, the corresponding phy_ID is 99.  Since that phy_ID has no other values of Md_t, the variable mean is missing. 

 

 

Here is a sample of the dataset and the expected value of “mean”:

 


 
  
  pat_ID
  
  
  phy_ID
  
  
  value
  
  
  mean
  
 
 
  
  1
  
  
  99
  
  
  1.2
  
  
  .
  
 
 
  
  2
  
  
  100
  
  
  1.1
  
  
  1.45
  
 
 
  
  3
  
  
  100
  
  
  1.4
  
  
  1.3
  
 
 
  
  4
  
  
  100
  
  
  1.5
  
  
  1.25
  
 
 
  
  5
  
  
  101
  
  
  2.3
  
  
  2.2
  
 
 
  
  6
  
  
  101
  
  
  2.2
  
  
  2.3
  
 
 
  
  7
  
  
  102
  
  
  1.9
  
  
  1.8
  
 
 
  
  8
  
  
  102
  
  
  1.8
  
  
  1.9
  
 


 

 

Any help would be much appreciated.
Thank you!Caroline 		 	   		  
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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