On Wed, 22 May 2013, artur bala wrote:
Dear all,
I use a sample restriction command into a "foreach" loop based on an index
variable.
The problem arises when for a specific index variable the sample restriction
leaves no observation and then the loop stops running notifying that no
observation would be left.
I would expect/prefer that the loop keep running through the next value of
the index variable instead of shutting down.
Is there any way to have the loop work beyond this "impediment"?
You can use the "catch" modifier, as in
<hansl>
nulldata 30
set seed 1234
small = uniform()
smaller = uniform() * 0.5
big = uniform() * 10
series x = NA
loop foreach i big small
catch smpl smaller>$i --restrict --replace
if !$error
series x = $i
endif
end loop
smpl full
print x -o
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------