example2 hello world
* Which works because we created the variables hello and world

example2 hello world
* This does not work because the above command already renamed the variables hello and world

* There is a lot of trickiness involved in effectively programming the syntax command and unfortunately it can be very frustrating because the only feedback stata gives is "invalid syntax" when something goes wrong.

* Also, unfortunately stata does not have many actual coding examples in which syntax is displayed.

* However, I think the following example will go a long way to answering many questions.

* This is the start of a command that will simulate data and test different estimators on that data.

* It will also set default parameters if the user does not input parameters into the simulation directly.

* Before executing the command, the command will display to the user the parameter set to be estimated

cap program drop example3
program define example3, rclass

*
syntax [anything] [, NGrp(numlist >0 integer) NInd(numlist >0 integer) ///
Rgrp(numlist integer) Udist(string) NEXogenous NENdogenous]
* The first few letters being capital allows the user to abreviate the option to just those two or three letters.
* Set defaults if the user has not defined any.
if "`ngrp'"=="" local ngrp=50
if "`nind'"=="" local nind=20
if "`rgrp'"=="" local rgrp=0
if "`udist'"=="" local udist="rnormal()*5"

* This sets the local parameter exogenous to be equal to 1 by default unless the user specifies ontherwise
local exogenous=1
if "`nexogenous'"!="" local exogenous=0