Many many thanks for all your insights Clive, Scott and Steven. In the coming
days I will be working more on this issue and will keep you posted on further
details.
Alejandro
In message <[email protected]>
[email protected] writes:
>
> To avoid a lot of output, add "quietly" to the first "forvalues"
> statement.
>
> Here's another way:
>
> /* draw 'nsamps' random samples of size 'sampsize' from a population of
> size 'popsize */
> set more off
> capture log close
> log using rsamp, text replace
>
> clear
> set seed 234568888
>
> local sampsize 3
> local popsize 5
> local nsamps 2
>
> quietly forvalues j=1/`nsamps' {
> clear
> set obs `popsize' // population size
> tempfile t`j'
> gen pick=_n
> gen u=uniform()
> sort u
> keep in 1/`sampsize'
> gen sample=`j'
> save "`t`j''"
> }
>
> use "`t1'"
>
> forvalues j=2/`nsamps' {
> append using "`t`j''"
> }
> label var pick "Obs Number to Pick"
>
> sort pick
> drop u
> save d01, replace
>
>
>
>
>
--
Alejandro de la Fuente
QEH/Department of International Development
Oxford University
*
* 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/