> -----Original Message-----
> From: Preeti Rao [mailto:[email protected]]
> Sent: Wednesday, June 12, 2002 2:39 PM
> To: [email protected]
> Subject: st: looping
>
>
> I would like to calculate the Lomodrs function for around 100
> variables.
> I've named the variables var1, var2 .. I tried writing a
> small program,
> to put it in a loop, but am getting stuck someplace. Can
> someone please
> correct me?
>
> --------do-lomodr.do--------------
> Set memory = 32000
> Set matsize = 800
> Program define calclomodr
> Use d:\all_variable.dta
> Local v = 1
> While 'v' < 100
> Gen t = _n
> Tsset t
> Lomodrs var'v'
> Local v = 'v' + 1
> End
In general, you will get better feedback if you include the output from
a program that isn't working, which will usually give clues about
*where* the program is breaking. That said, there are several things
here:
-- Don't capitalize the commands -- Stata is Case Sensitive.
-- No need to generate the time variable inside the loop; in fact, this
will crash on the second time through.
-- When referring to a local macro, be sure to distinguish the opening
and closing characters -- ` vs '
-- No need to define a program to loop. You can do this as:
set memory 32000
set matsize 800
use d:\all_variable.dta
foreach v of varlist v1-v100 {
lomodrs `v'
}
--Or you could do the loop with numbers rather than variables:
forval v=1/100 {
lomodrs var`v'
}
--Nick Winter
*
* 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/