Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: recoding variables with different min & max into standard scale


From   Daniel Laurison <[email protected]>
To   [email protected]
Subject   st: recoding variables with different min & max into standard scale
Date   Wed, 2 Feb 2011 09:36:18 -0800

Hi nice & smart Stata people,

I have a problem that I think should have a simple, elegant solution
that I'm just overlooking... but I can't find it.

I have a couple hundred variables all with different ranges, and I
just need to get them all to be 0-1 (not dummies, but continuous with
the min value 0 and max value 1 and everything in between keeping its
original proportions; I'd be just as happy with 0-100 or etc.).  I
don't need ranks or "standardized" i.e. egen std(var) values.  The
mathematical formula is simply [var- min(var)]/[max(var)-min(var)] but
I can't figure out how to make Stata do that; I know I could get the
ranks, but I want to keep the relative values.  My workaround is to
egen the constant max & min of each var, and then do a foreach loop
with the maxvars & minvars for each var in the formula... but there
has to be a neater, more elegant solution, right?

Thanks for any help, and apologies if this is something obvious - I've
googled & asked around, to no avail thus far, so I'm turning to you
all.

- Daniel


--
Daniel Laurison
PhD Candidate
Department of Sociology
University of California, Berkeley

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index