Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Uppercase arguments for programs

From   Bert Lloyd <>
To   statalist <>
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"

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

. 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:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index