Hi everyone I am a PHD student in Economics in York University (UK). I have
been working on a do file, trying to re-rank some 60 variables I have in my
database. My problem is that i cannot make my loop a "smart" loop so to
speak. My re-ranking do file (is probably very inefficient because i am
relatively new to Stata) is based on pair-wise differences among variables.
So I need Stata to keep on performing the series of programs I wrote until
the condition that none of these 59 differences is negative. I have been
able to create a "dumb loop" like: local i=1 while `i' <=23 { set more off
quietly zero quietly primo quietly secondo finale_bis display `i' local
i=`i'+1 }
it takes 23 iterations until all differences are >=0
What I would need is for stata to do something like
Now, for some reason I cannot explain myself, it works for only 9
iterations and then it stops. So it is not "understanding" the if condition
properly.This statement is reinforced by the fact that if I run this when
only, say, 3 more iterations are needed it does nothing as after the first
nine.
The third and last way I could come up with was to "encapsulate" that huge
if condition into a single variable......
but that's where I get into a never ending loop! finale_bis produces the
number of differences (count if.....) still negative but, after reaching
the zero, it keeps on performing the operations.
Thank you all very much for your kind attention
Best regards Ciao
********************************************************************
Roberto Mura
address in the UK
22, Turners Croft
Heslington
York
YO105EL
tel: 0044 (0)1904 412 869
indirizzo in Italia
via Capo Sandalo 4
09042 Monserrato, Cagliari