Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: Convention RE ado's which may redefine value labels


From   "Nick Winter" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Convention RE ado's which may redefine value labels
Date   Tue, 19 Nov 2002 13:39:51 -0500

Interestingly, -encode- does not simply overwrite an existing value
label.  Much more strangely (from my point of view), it simply adds
values to the value label, and generates the new encoded variable
appropriately.  So nothing is overwritten, with respect to the
already-labeled variables.

Still, all things considered I would consider this a misfeature or
bug.Consider the following:

. use auto
(1978 Automobile Data)

. d

Contains data from auto.dta
  obs:            74                          1978 Automobile Data
 vars:            12                          27 Sep 2001 11:10
 size:         3,478 (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   %8.0g       origin     Car type
------------------------------------------------------------------------
-------
Sorted by:  foreign  

**NOTE THAT THE VARIABLE foreign has value label "origin"

. encode make, gen(origin)

. d

Contains data from auto.dta
  obs:            74                          1978 Automobile Data
 vars:            13                          27 Sep 2001 11:10
 size:         3,774 (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   %8.0g       origin     Car type
origin          long   %17.0g      origin     Make and Model
------------------------------------------------------------------------
-------
Sorted by:  foreign  
     Note:  dataset has changed since last saved

**NOW, BOTH foreign AND THE NEW VARIABLE origin
**HAVE THE VALUE LABEL "origin"

. la list origin
origin:
           0 Domestic   <======= original
           1 Foreign    <======= values
           2 AMC Concord   <========new values start here
           3 AMC Pacer
           4 AMC Spirit
           5 Audi 5000
           6 Audi Fox
<<snip>>
          74 VW Scirocco
          75 Volvo 260

**AND THE NEW origin VARIABLE BEGINS WITH "2" rather than "1":

. ta origin, nol

   Make and |
      Model |      Freq.     Percent        Cum.
------------+-----------------------------------
          2 |          1        1.35        1.35
          3 |          1        1.35        2.70
          4 |          1        1.35        4.05
          5 |          1        1.35        5.41
          6 |          1        1.35        6.76
          7 |          1        1.35        8.11
          8 |          1        1.35        9.46

<<snip>>

         73 |          1        1.35       97.30
         74 |          1        1.35       98.65
         75 |          1        1.35      100.00
------------+-----------------------------------
      Total |         74      100.00


--Nick Winter
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index