Search
   >> Home >> Resources & support >> FAQs >> Option limit

Is there any way to get around the 70-option limit in Stata’s syntax command?

Title   Option limit
Author Douglas Stave, Fargo Home Mortgage, MO, USA
Date August 2006

You can use the * option and the ability to reset local macro 0 to cascade multiple commands to get around the 70-option limit of syntax. For example,

 program lots_of_options
     syntax [, opt1 opt2 opt3 opt4 opt5 opt6 opt7 opt8 opt9 opt10 opt11
 opt12 opt13 opt14 opt15 opt16 opt17 opt18 opt19 opt20 opt21 opt22 opt23
 opt24 opt25 opt26 opt27 opt28 opt29 opt30 opt31 opt32 opt33 opt34 opt35
 opt36 opt37 opt38 opt39 opt40 opt41 opt42 opt43 opt44 opt45 opt46 opt47
 opt48 opt49 opt50 opt51 opt52 opt53 opt54 opt55 opt56 opt57 opt58 opt59
 opt60 opt61 opt62 opt63 opt64 opt65 opt66 opt67 opt68 opt69 opt70 opt71]
     macro list
 end

 . lots_of_options, opt1 opt50 opt71
 invalid syntax
 r(197);

By using the * option, which puts extra options into a local macro called options, you can cascade syntax commands.

 program lots_of_options
     syntax [, opt1 opt2 opt3 opt4 opt5 opt6 opt7 opt8 opt9 opt10 opt11
 opt12 opt13 opt14 opt15 opt16 opt17 opt18 opt19 opt20 opt21 opt22 opt23
 opt24 opt25 opt26 opt27 opt28 opt29 opt30 opt31 opt32 opt33 opt34 opt35
 opt36 opt37 opt38 opt39 opt40 opt41 opt42 opt43 opt44 opt45 opt46 opt47
 opt48 opt49 opt50 opt51 opt52 opt53 opt54 opt55 opt56 opt57 opt58 opt59
 opt60 opt61 opt62 opt63 opt64 opt65 opt66 opt67 opt68 opt69 *]
     local 0 `", `options'"'
     syntax [, opt70 opt71]
     macro list
 end

 . lots_of_options, opt1 opt50 opt71
 S_MACH:         PC
 S_OS:           Windows
 S_FLAVOR:       Intercooled
 S_StataSE:      SE
 S_level:        95
 S_ADO:          UPDATES;BASE;SITE;.;PERSONAL;PLUS;OLDPLACE
 _opt71:         opt71
 _0:             , opt71
 _opt50:         opt50
 _opt1:          opt1
 _4:             opt71
 _3:             opt50
 _2:             opt1
 _1:             ,

This method can be replicated to allow any number of options.

 program lots_of_options
     syntax [, opt1 opt2 opt3 opt4 opt5 opt6 opt7 opt8 opt9 opt10 opt11
 opt12 opt13 opt14 opt15 opt16 opt17 opt18 opt19 opt20 opt21 opt22 opt23
 opt24 opt25 opt26 opt27 opt28 opt29 opt30 opt31 opt32 opt33 opt34 opt35
 opt36 opt37 opt38 opt39 opt40 opt41 opt42 opt43 opt44 opt45 opt46 opt47
 opt48 opt49 opt50 opt51 opt52 opt53 opt54 opt55 opt56 opt57 opt58 opt59
 opt60 opt61 opt62 opt63 opt64 opt65 opt66 opt67 opt68 opt69 *]
     local 0 `", `options'"'
     syntax [, opt70 opt71 opt72 opt73 opt74 opt75 opt76 opt77 opt78
 opt79 opt80 opt81 opt82 opt83 opt84 opt85 opt86 opt87 opt88 opt89 opt90
 opt91 opt92 opt93 opt94 opt95 opt96 opt97 opt98 opt99 opt100 opt101
 opt102 opt103 opt104 opt105 opt106 opt107 opt108 opt109 opt110 opt111
 opt112 opt113 opt114 opt115 opt116 opt117 opt118 opt119 opt120 opt121
 opt122 opt123 opt124 opt125 opt126 opt127 opt128 opt129 opt130 opt131
 opt132 opt133 opt134 opt135 opt136 opt137 opt138 *]
     local 0 `", `options'"'
     syntax [, opt139 opt140 opt141 opt142 opt143 opt144 opt145 opt146
 opt147 opt148 opt149 opt150 opt151 opt152 opt153 opt154 opt155 opt156
 opt157 opt158 opt159 opt160 opt161 opt162 opt163 opt164 opt165 opt166
 opt167 opt168 opt169 opt170 opt171 opt172 opt173 opt174 opt175 opt176
 opt177 opt178 opt179 opt180 opt181 opt182 opt183 opt184 opt185 opt186
 opt187 opt188 opt189 opt190 opt191 opt192 opt193 opt194 opt195 opt196
 opt197 opt198 opt199 opt200 opt201 opt202 opt203 opt204 opt205 opt206
 opt207]
     macro list
 end

 . lots_of_options, opt1 opt50 opt71 opt124 opt138 opt180 opt207
 S_MACH:         PC
 S_OS:           Windows
 S_FLAVOR:       Intercooled
 S_StataSE:      SE
 S_level:        95
 S_ADO:          UPDATES;BASE;SITE;.;PERSONAL;PLUS;OLDPLACE
 _opt207:        opt207
 _opt180:        opt180
 _0:             , opt180 opt207
 _opt138:        opt138
 _opt124:        opt124
 _opt71:         opt71
 _opt50:         opt50
 _opt1:          opt1
 _8:             opt207
 _7:             opt180
 _6:             opt138
 _5:             opt124
 _4:             opt71
 _3:             opt50
 _2:             opt1
 _1:             ,

This method still catches any option that does not exist.

 . lots_of_options, opt1 opt50 opt71 opt124 opt138 opt180 opt207 opt208
 option opt208 not allowed
 r(198);
    
 . lots_of_options, opt1 opt50 opt71 opt124 opt138 opt180 opt207 otheropt
 option otheropt not allowed
 r(198);
The Stata Blog: Not Elsewhere Classified Find us on Facebook Follow us on Twitter LinkedIn Google+ Watch us on YouTube