*! version 2.1.2 5August2019

Title

nscale -- Program to recode variables to lie between 0 and 1

Syntax

nscale varlist
[, options]

Main
generate(namelist) create namelist so that transformed values of the nth variable of varlist are stored in the nth variable of the namelist

prefix(name) create new variables with prefix name

nopostfix replace existing variables

missing(#) set observations to missing (.) if their value is equal to #; can be combined with up or down

up set observations to missing (.) if their value is greater than or equal to the number assigned by missing(#)

down set observations to missing (.) if their value is less than or equal to the number assigned by missing(#)

reverse reverse variable coding

tab tabulate new variables

If neither generate(varlist), prefix(name) nor nopostfix is set, nscale creates new variables with postfix _01.

nopostfix may not be combined with generate(varlist) or prefix(name).

generate(varlist) may not be combined with prefix(name).

up may not be combined with down.

Description

nscale provides a convenient way to recode variables in varlist
to lie between 0 and 1 via dividing var-min(var) by max(var)-min(var).
nscale can recode many variables at once and has options generate(namelist) and prefix(name)
which work in the similar manner as Stata’s default command recode does.
It is also possible to store transformed values in existing variables with option nopostfix.

nscale can set specific value or interval to missing (.) as well. For example,
if a survey question q1 coded DK as 98 and miscellaneous as 99
and you want to exclude those values from analysis, just type: nscale q1 , m(98) up.
Then nscale sets all observations whose value is greater than or equal to 98 to missing (.).
The option down combined with option missing(#) works similarly.

Moreover, nscale does reverse coding with option reverse and tabulates new variables with option tab.

Examples

. nscale var

. nscale var1 var2 , gen(nv1 nv2)

. nscale varlist , pre(new_)

. nscale varlist , m(9)

. nscale varlist , r t

. nscale varlist , nopost