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.