[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
RE: st: RE: RE: loop [ignore previous one (from this message), sorry!!!]
> Thank you so much. After I made that change "gen long
> `pat02'=." it worked.
> Also thank you for your hints/program. Probably I
> shouldn't ve posted
> this question. Rather I better to take a course in
> programming. But if you
> have the answer at hand, would you be able to give me some
> general rules/if
> possible, some tricks for this problem to be more
> efficient? This program
> now works pretty fine with less than like 12 variables.
> Everything works
> fine except a bit slow (10 and less variables kind of fast
> enough). But
> when I play around with it using like 15 variables, it just
> takes forever to
> produce the results (like 10 minutes). I think it's
> probably related to the
> forval command in the middle part of this program. But I
> couldn't find a
> better way. Or, if I want program an ado file to do what I
> want (exhaust
> combinations), slowness should be expected.
There are two root problems:
1. The size of the problem grows with the number of
variables k roughly as 2^k. E.g. 2^15 is 32768, 2^10 is 1024.
This remains true whatever you do.
2. Stata as an interpreted language is fast, but
cannot be fast as compiled code. -forval- is pretty
fast as interpreted code goes. Translating a -while-
into a -foreach- or -forval- will speed your code up
a bit, but possibly only by a small fraction.
* For searches and help try: