I hope a macro guru might be able to help me with this problem.
Either I have made a mistake or there is a Stata bug.
I am developing a program to format the output from Roger Newson's -parmby-
Here is a snippet of code.
program define showparmest
version 8.2
syntax using/ [, Clearfile Sort ciform(string)]
preserve
qui compress
qui {
// identify the type of command
local command `e(cmd)'
// identify categorical variables used with "i." in an xi
local cmdline `r(command)'
foreach word of local cmdline {
if substr("`word'",1,2) == "i." {
local tname = substr("`word'",3,.)
local catlist `catlist' `tname' // macro catlist
comtains i.cat vars
} // with i. stripped off
}
// get levels and omitted category for catvars
foreach catvar of local catlist {
levels `catvar', local(`catvar'lev) // lev in
VARNAMElev
local `catvar'omit : char `catvar'[omit] // omit in
VARNAMEomit
if "``catvar'omit'" == "" {
local `catvar'omit : word 1 of ``catvar'lev' // low cat if
no char[omit]
}
foreach num of local `catvar'lev { // get value
labels
local `catvar'lab`num': label `catvar' `num'
noi di "``catvar'lab`num''"
}
}
noi des sex edcat
noi lab list sex edcode2
noi tabl edcat
The key section to pay attention to is the section beginning // get value
labels.
This section uses the extended macro function to assign value labels to macros.
In the //get value labels section, in the foreach cycle, -sex- is processed
first then -edcat- . Both variables have value labels assigned but Stata
only sees the labels for -sex-, not for -edcat-
Here is the output:
This is the parmby output to show you what I am doing. This is a nonsense
regression for test purposes.
. parmby "xi:logistic married haq pain i.sex fatigue i.edcat age edlevel ",
label eform format(estimate min95 max95 %8.2f p %8.1e) saving(killme,replace)
Command: xi:logistic married haq pain i.sex fatigue i.edcat age edlevel
i.sex _Isex_0-1 (naturally coded; _Isex_0 omitted)
i.edcat _Iedcat_0-4 (naturally coded; _Iedcat_2 omitted)
Logistic regression Number of obs = 7415
LR chi2(10) = 369.84
Prob > chi2 = 0.0000
Log likelihood = -4290.4222 Pseudo R2 = 0.0413