I think what you are looking for is -unabcmd-, e.g.
unabcmd `subcmd'
if r(cmd)=="regress" {
etc
}
David
[email protected]
-----Original Message-----
From: Jun Xu [mailto:[email protected]]
Sent: 25 January 2005 02:40
To: [email protected]
Subject: st: get full command name without invoking the command
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/
*
* 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/