Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: How "sort" and "by" behave


From   [email protected]
To   [email protected]
Subject   st: How "sort" and "by" behave
Date   Mon, 18 Aug 2003 19:59:49 +0200

Dear Stata-listers,

I have an observation to make, I have a data set that is sorted by site,
subject and rnum and I am always creating / manipulating  variables at the
subject level (rnum=1,..,20), as follows

/***	1st run **/
sort site subject rnum 
forval X = 1/6 { 
	genl prevcheck`X'=moa`X'[_n-1] if tag`X'==1 
}

/***	2nd run **/
sort site subject rnum 
forval X = 1/6 { 
	genl prevcheck`X'=moa`X'[_n-1] if tag`X'==1 , by(site subject)
}

The variables prevcheck1-prevcheck6 were identical from the two runs - can I
trust that "by(site subject)" will always be redundant once Stata registers
the sorting structure.

Many thanks for your thoughts in advance.


Amani

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index