Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Uppercase arguments for programs
From
Bert Lloyd <[email protected]>
To
statalist <[email protected]>
Subject
st: Uppercase arguments for programs
Date
Thu, 2 Feb 2012 21:04:16 -0500
Dear Statalist,
Is there a way to use uppercase arguments for programs? The use of
uppercase letters to designate the required portion of the argument's
name seems to prevent this.
Consider the following simple example:
--- begin example code ---
cap program drop uppercase_argument
program define uppercase_argument
syntax, K(integer)
di "there are `K' right-hand-side variables"
di "there are `k' right-hand-side variables"
local K = `k'
di "there are `K' right-hand-side variables"
end
capture noisily uppercase_argument, K(3)
di _rc
capture noisily uppercase_argument, k(3)
--- end example code ---
This yields the following output:
--- begin output ---
. capture noisily uppercase_argument, K(3)
option k() required
. di _rc
198
.
. capture noisily uppercase_argument, k(3)
there are right-hand-side variables
there are 3 right-hand-side variables
there are 3 right-hand-side variables
--- end output ---
There is a workaround that involves creating new local macros within
the program, e.g. in the above a line like
local K = `k'
but this is tedious and leads to errors, both from simple typos and
from Alice's White Knight "what the name of the song is called" type
mistakes confounding the macro with the name of the macro, etc.
Many thanks in advance for any suggestions.
- BL
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/