Another take on this is a bit different.
You just need to think of fixing the difficulty
_upstream_ of whatever tabulation command
you want to use, not in terms of heavy hacking
at tabulation time.
So Buddy just needs to ensure that variable
labels start with the corresponding variable
names. This is entirely under the user's control.
You can also do this temporarily.
. sysuse auto, clear
(1978 Automobile Data)
. table foreign rep78
----------------------------------------
| Repair Record 1978
Car type | 1 2 3 4 5
----------+-----------------------------
Domestic | 2 8 27 9 2
Foreign | 3 9 9
----------------------------------------
. preserve
. foreach v of var for rep78 {
2. label var `v' "`v' `: variable label `v''"
3.
. }
. table foreign rep78
----------------------------------------
foreign | rep78 Repair Record 1978
Car type | 1 2 3 4 5
----------+-----------------------------
Domestic | 2 8 27 9 2
Foreign | 3 9 9
----------------------------------------
. restore
. table foreign rep78
----------------------------------------
| Repair Record 1978
Car type | 1 2 3 4 5
----------+-----------------------------
Domestic | 2 8 27 9 2
Foreign | 3 9 9
----------------------------------------
The only tricky bit is the loop over variables,
which can be converted into a little utility,
say
* prefixes variable names to variable labels
program varvarlabel
version 8.2
syntax varlist
foreach v of local varlist {
label var `v' `"`v' `: variable label `v''"'
}
end
The resulting variable labels might be too long for
a pretty table, or you might lose some of the original
variable labels, or both, but this is an attempt
to give you what you asked for.
Nick
[email protected]
Philip Ryan
> In response to the second part of the question, I think this is bit
> trickier. The display of data under -table- is controlled by
> -tabdisp-. This is an in-built command, so not amenable to
> tinkering by
> end-users. -tabdisp- behaves a bit like -tabulate- in that,
> by default,
> these commands display the variable label, not the variable
> name, in the
> headers. -tabulate- has a -nolabel- option that allows you
> to choose to
> display the variable name, but you don't get the choice of
> both. -tabdispl- does not even have a -nolabel- option (and
> consequently
> -table- does not permit it).
>
> So... I think if you want to get variable name and label into
> the row/col
> headers of a cross-tabulation display, then you might need to
> knit your own
> from a reasonably low level. I haven't looked thoroughly at
> the enormous
> number of user written programs in the general area of
> tables, so maybe
> someone has already tackled this.
Buddy
> >I've checked the user's guide, programming and the
> >reference guide. I want to use describe and only want
> >the variable name and variable label - not the other
> >information. Also, when I use a table command - I
> >would like to see BOTH the variable name and the
> >variable label - is this possible?
*
* 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/