Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: rescaling a variable by the maximum value question


From   "JVerkuilen (Gmail)" <jvverkuilen@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: rescaling a variable by the maximum value question
Date   Sat, 13 Oct 2012 01:49:07 -0400

I'm sure I'm simply overlooking something easy but I want to make a
new variable that is rescaled by dividing by the maximum value of the
old one. Old variable: 1, 2, 3, 4. New variable should be 0.25, 0.5,
0.75, 1.

The syntax

     gen newvar = oldvar/max(oldvar)

does not work and I understand why it doesn't, because max doesn't
work that way. Is there a straightforward way to do this? (Yes I could
simply

     summarize oldvar

and pick out the max by hand and rescale. I'd like to avoid that, if
possible. ;)
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index