Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: RE: Varname default in a program

From   "Nick Cox" <>
To   <>
Subject   st: RE: Varname default in a program
Date   Fri, 9 Jul 2010 19:24:23 +0100

I don't think there is a way to do this with -syntax- but that doesn't

Within your program, after your -syntax- statement you go 

if "`pvar'" == "" local pvar "<default>" 

as if -pvar()- was not selected, the local macro pvar will be empty. Or,
rather, the local macro pvar will be undefined, but that's the same to

By the way, the -help- for -syntax- should be considered complete, so
guessing that there are undocumented extras is not a good strategy. 


Dani Tilley

I'm trying to write a program that will have the following syntax

syntax varlist(min=1 max=5), [Pvar(varname)]

However, I want the to have a default value for pvar so that when users
-command var1 var2- the program returns no error and uses the default
for pvar. I know how this is done for numeric variables but can't do it
in this 
context. I tried [Pvar(varname default)] where default is a variable but

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index