.- help for ^for3^ (ip8.1: STB-30) .- Repeat command with specified sets of arguments ----------------------------------------------- ^for3^ list1 [\list2 [\list3...]] [^,^ ^l^type^(^typelist^)^ ^noh^eader ^nos^top ^p^ause ]^:^ stata_cmd Description ----------- ^for3^ repeats stata_cmd substituting for ^@@^ in stata_cmd each member of list1, substituting for ^@@@@^ each member of list2 (if given), and so on. Options ------- ^ltype(^typelist^)^ determines the types of list1, list2, ... . Items in typelist correspond to list1, list2, ... respectively. Valid list types are ^n^umeric, ^a^ny and ^v^arlist, with the following meanings: ^numeric^ specifies that the corresponding list is to consist only of non- negative integers. Such a list may contain range abbreviations (^-^) and increment indicators (^/^). For instance, ^2-6/2^ is expanded by ^for3^ to ^2 4 6^. ^any^ specifies that the corresponding list is to be given no special inter- pretation. Note that if the list contains embedded space(s), the latter must be entered as #'s in order to avoid confusing Stata's parser. For example, ^if#x==1^ will be translated to ^if x==1^ when stata_cmd is executed. ^varlist^ specifies that the corresponding list is interpreted as a varlist ---all the variables must exist and standard Stata varlist syntax, such as ^sx*^ to mean all variables that start with ^sx^, is allowed. If you omit ^ltype()^ altogether, or specify fewer types than lists, any types not specified are taken as ^v^arlist by default. ^noheader^ specifies that the substituted Stata command is not to be shown before execution. If ^noheader^ is not specified, the substituted command is shown. ^nostop^ specifies that the command is to continue to be repeated with the sub- sequent elements of list1 (list2, etc) even if one of the replications results in an error (nonzero return code). ^pause^ pauses output after each execution of stata_cmd. This may be useful with Stata for Windows when stata_cmd produces more than one graph. Stata tends to write each graph on top of the previous without pausing, allowing you to see only the last one. Use of ^pause^ will overcome the problem. Remark ------ You may occasionally wish to include a comma or a colon in a list of type ^any^. To avoid being mistaken for part of the syntax of the ^for3^ command itself, these characters must be repeated (e.g. ^::^ will be translated to ^:^). Examples -------- Use of ^for3^ identical to ^for2^: . ^for3 q16-q25: replace @@=@@+1^ . ^for3 q16-q25, noheader: replace @@=@@+1^ Functionality identical to ^for2^, slightly different syntax: . ^for3 u1 u2 u3, ltype(any): gen @@=uniform()^ . ^for3 -9 -99, ltype(any): mvdecode var*, mv(@@)^ . ^for3 3-18/3, ltype(numeric): gen group@@ = group+@@^ New functionality not available with ^for2^: . ^for3 12.3 4.4 2.8\a b c, ltype(any varlist): ttest @@@@=@@^ . ^for3 12.3 4.4 2.8\a b c, ltype(a): ttest @@@@=@@^ [same] . ^for3 ch1-ch3\cga cgb cgd: ttest @@=@@@@^ . ^for3 ch*\cg*: ttest @@=@@@@^ Author ------ Patrick Royston Royal Postgraduate Medical School, London FAX: (011)-44-181-259-8573 Also see -------- STB: ip8.1 STB-30; ip8 STB-26 Manual: [5u] for On-line: help for @quietly@