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: RE: Comparing variables by observation
From 
 
"Martin Weiss" <[email protected]> 
To 
 
<[email protected]> 
Subject 
 
st: RE: Comparing variables by observation 
Date 
 
Tue, 21 Sep 2010 20:55:42 +0200 
<>
Just show us the code that creates the wrong counts. This code seems to work
reasonably well:
*************
clear*
set obs 20
set seed 3201
foreach var of newlist X1-X3{
	gen `var'=irecode(runiform(), 0,.2,.4,.45,.5,.7,.8,.9,1)
}
cou if 5>= X1 & X1>=X2 & X2 >=X3 & X3 >=4
cou if X1<=3& 5<= X3
*************
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Anisa Shyti
Sent: Dienstag, 21. September 2010 20:48
To: [email protected]
Subject: st: Comparing variables by observation
Hello Everyone,
Hello Martin,
I am facing the following problem: I have three variables X1 X2 X3
(taking values from 1 to 10) and I need to compare their values, by
observation, according to several conditions (which are theoretically
derived) of the form, examples: (1) 5>= X1 >=X2 >=X3 >=4; (2) X1<=3
and 5<= X3.  I need to evaluate each condition on the data by counting
the number of times it is met, in order to classify the observations.
I tried several approaches, but the total number of classified
observations exceeds the total number of observations.  So, I am
guessing I have some redundant counts - maybe I am doing something
wrong with the coding (given that the conditions are correct).
Thank you very much for your help and insights.
Anisa
*
*   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/