Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: get full command name without invoking the command


From   "Jun Xu" <[email protected]>
To   [email protected]
Subject   st: get full command name without invoking the command
Date   Mon, 24 Jan 2005 20:39:38 -0600

I am writing a command like

mycmd reg y x1 x2 x3, by(groupvar)
or
mycmd logi y x1 x2 x3, by(groupvar)

it will invoke some built-in Stata command, and does things differnt than bysort groupvar: reg y x1 x2 x3 or parmest. However, I'd like it to produce some error message if it is not the Stata estimation command compatible with mycmd. One way is to blindly estimate the model using

reg y

in my codes first and get the e(cmd) macro and then put something at the very beginning like
if "`e(cmd)'"=="regress" {
then fine
}

else {
display error and exit
}
I think this is dumb. What I am thinking about is the alternative. Let's assume I can strip off reg or logit and put it into a local like sumcmd. Is there anyway that once I grab subcmd reg, I can use someway to expand it to regress using some Stata macro command. I can automatically expand reg regr regres regress into regress, such that in check codes I can just specify once regress, such as

local cmd `subcmd' (which is reg) => `subcmdfull' (which is regress)

if "`subcmdfull'"=="regress" {
fine
}
else {
kick out
}

and I don't have to exhaust all possibilities of abbreviations.

Jun Xu
Department of Sociology
Indiana University

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar � get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index