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: Creating a variable with a value conditional on other variables
From 
 
Nick K <[email protected]> 
To 
 
<[email protected]> 
Subject 
 
st: Creating a variable with a value conditional on other variables 
Date 
 
Sat, 9 Apr 2011 13:05:54 +0200 
Hi,
I'm new to Stata and am having a hard time figuring out a relatively
simple problem. I'm experienced with other programming languages and
SQL so pseudo code may get my point across more clearly.
foreach(observation)
{
    variable Xi = average(Y) if A != Ai
}
Basically it would go over every observation and create a variable of
the average of some other variable NOT INCLUDING the variable's value
for the current row. So X is the average of Y for all observations
EXCEPT the current one.
Thanks
*
*   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/
*
*   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/