Statalist


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

st: RE: AW: Simulation in Stata


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: AW: Simulation in Stata
Date   Thu, 28 May 2009 11:31:42 +0100

My comment is a bit different. What Susan apparently user wants can be
achieved by 

expand 10 
sort id_psu, stable 
gen no = _n 

In short, the -stable- option of -sort- is intended for this purpose. 

In a big dataset, that last should be

gen long no = _n 

Nick 
[email protected] 

Martin Weiss

[...] 

*************
expand 10
gen no = _n

sort id_psu no
drop no
gen no = _n
*************

is too complicated as you first have Stata record the current sort order
via
"_n" , then -sort- on "id_psu" and then -drop- "no" - only to recreate
it in
the next step.

[...] 


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index