Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reversing scale in variable

    In our stata data set we have a variable confidence scale from 1 to 4, where 1 is most confident and 4 is least confindent. However, we want to reverse this so 1 is the least confident and 4 is the most confident. Does anyone know if this is possible and how to do it? Thanks!

  • #2
    Code:
    replace v = 5 - v 
    takes care of the arithmetic but the more difficult issue is reversing any value labels (and variable label or notes if there are mentions of details you want to change). A quick

    Code:
    search reverse 
    yields some plausible hits, with apologies if I missed some.


    dm7 from http://www.stata.com/stb/stb7
    STB-7 dm7. Utility to reverse variable coding. / STB insert by Prof. Marc
    Jacobs, Dept of Sociology, / University of Utrecht, The Netherlands. /
    Support: Fax: 011-31-30 53 4405 / After installation, see help omscore.

    label_reverse from http://www.stata.com/users/brising
    label_reverse: Reverses value labels for poorly ordered ordinal variables
    / Bill Rising / Dept. of Bioinformatics and Biostatistics / University of
    Louisville / email: brisinglouisville.edu

    rev from http://fmwww.bc.edu/RePEc/bocode/r
    'REV': module to reverse value order of variables / rev reverses the value
    order of each variable specified in / varlist. The created variable
    rv_varname contains the values of / the original variable in reversed
    order. Value labels are / reversed accordingly. / KW: data management /

    revrs from http://fmwww.bc.edu/RePEc/bocode/r
    'REVRS': module to reverse variable value order / This is a module to
    reverse the order of a variable's values and / maintain specified value
    labels. `revrs' is especially helpful / for quickly recoding multiple
    categorical or ordinal response / variables to follow a similar direction.

    revv from http://fmwww.bc.edu/RePEc/bocode/r
    'REVV': module to reverse value order of variables / revv reverses the
    order of values of each variable specified / in varlist. New variables are
    created containing the reversed / value order of the original variables.
    In a second step the / value labels are reversed accordingly. / KW: data

    vreverse from http://fmwww.bc.edu/RePEc/bocode/v
    'VREVERSE': module to reverse existing categorical variable / vreverse
    generates a new variable as a reversed copy of an / existing categorical
    variable with integer values. Suppose that / in the observations
    specified values vary between minimum min / and maximum max. Then values

    The last -- vreverse (SSC) -- happens to be the most familiar to me, so how does it work?

    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . label def rep78 1 Abysmal 2 Awful 3 Adequate 4 Admirable 5 Amazing
    
    . label val rep78 rep78
    
    . tab rep78
    
         Repair |
    Record 1978 |      Freq.     Percent        Cum.
    ------------+-----------------------------------
        Abysmal |          2        2.90        2.90
          Awful |          8       11.59       14.49
       Adequate |         30       43.48       57.97
      Admirable |         18       26.09       84.06
        Amazing |         11       15.94      100.00
    ------------+-----------------------------------
          Total |         69      100.00
    
    . vreverse rep78, gen(rep78_2)
    
    . tab rep78_2
    
         Repair |
    Record 1978 |      Freq.     Percent        Cum.
    ------------+-----------------------------------
        Amazing |         11       15.94       15.94
      Admirable |         18       26.09       42.03
       Adequate |         30       43.48       85.51
          Awful |          8       11.59       97.10
        Abysmal |          2        2.90      100.00
    ------------+-----------------------------------
          Total |         69      100.00

    Comment

    Working...
    X