Dear Nick and Statalist
On
http://www.stata.com/statalist/archive/2003-08/msg00582.html
Nick Cox writes "It is the user's responsibility to consider whether the
copied variable label and characteristics
also apply."
In particular I want to draw the attention to the interaction between
-numlabel- and -vreverse-
If you first -numlabel label, add- and after -vreverse varname,
generate(newvar)-, then the numbers in the lables will be wrong for newvar.
The -vreverse- generates a new lable with the same name as newvar, to my
(very modest) experience it is not possible to subsequently remove the
numbers from the new lable.
So (at the moment) the best way to do what people want, assuming they want
the right lables on both the original variable and the new variable, seems
to me to be
-numlabel label, remove- -vreverse varname, generate(newvar)- -numlabel
label, add- -numlabel newlabel, add-
Renzo Comolli
E.g.
. sysuse auto, clear
(1978 Automobile Data)
. numlabel origin, add
. tab foreign
Car type | Freq. Percent Cum.
------------+-----------------------------------
0. Domestic | 52 70.27 70.27
1. Foreign | 22 29.73 100.00
------------+-----------------------------------
Total | 74 100.00
. tab foreign, nola
Car type | Freq. Percent Cum.
------------+-----------------------------------
0 | 52 70.27 70.27
1 | 22 29.73 100.00
------------+-----------------------------------
Total | 74 100.00
. vreverse foreign, generate(Foreign)
. tab Foreign
Car type | Freq. Percent Cum.
------------+-----------------------------------
1. Foreign | 22 29.73 29.73
0. Domestic | 52 70.27 100.00
------------+-----------------------------------
Total | 74 100.00
. tab Foreign, nola
Car type | Freq. Percent Cum.
------------+-----------------------------------
0 | 22 29.73 29.73
1 | 52 70.27 100.00
------------+-----------------------------------
Total | 74 100.00
. d
Contains data from C:\STATA8\ado\base/a/auto.dta
obs: 74 1978 Automobile Data
vars: 13 3 Oct 2002 13:53
size: 3,552 (99.9% of memory free)
----------------------------------------------------------------------------
---
storage display value
variable name type format label variable label
----------------------------------------------------------------------------
---
make str18 %-18s Make and Model
price int %8.0gc Price
mpg int %8.0g Mileage (mpg)
rep78 int %8.0g Repair Record 1978
headroom float %6.1f Headroom (in.)
trunk int %8.0g Trunk space (cu. ft.)
weight int %8.0gc Weight (lbs.)
length int %8.0g Length (in.)
turn int %8.0g Turn Circle (ft.)
displacement int %8.0g Displacement (cu. in.)
gear_ratio float %6.2f Gear Ratio
foreign byte %11.0g origin Car type
Foreign byte %11.0g Foreign Car type
----------------------------------------------------------------------------
---
Sorted by: foreign
Note: dataset has changed since last saved
. numlabel Foreign, remove
(no value label to be modified)
. numlabel Foreign, remove force
(no value label to be modified)
. numlabel Foreign, add
. tab Foreign
Car type | Freq. Percent Cum.
---------------+-----------------------------------
0. 1. Foreign | 22 29.73 29.73
1. 0. Domestic | 52 70.27 100.00
---------------+-----------------------------------
Total | 74 100.00
*
* 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/