Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
"Justina Fischer" <JAVFischer@gmx.de> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: rescaling a variable by the maximum value question |

Date |
Sat, 13 Oct 2012 10:02:35 +0200 |

you can generate a variable that takes on the maximum value e.g. su age gen var = `r(max)' gen newvar = oldvar/var see also return list after the sum command HTH Justina -------- Original-Nachricht -------- > Datum: Sat, 13 Oct 2012 01:49:07 -0400 > Von: "JVerkuilen (Gmail)" <jvverkuilen@gmail.com> > An: statalist@hsphsun2.harvard.edu > Betreff: st: rescaling a variable by the maximum value question > 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/ * * 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/

**Follow-Ups**:**Re: st: rescaling a variable by the maximum value question***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: rescaling a variable by the maximum value question***From:*"JVerkuilen (Gmail)" <jvverkuilen@gmail.com>

- Prev by Date:
**Re: st: Checking to see if the association between two variables is linear or otherwise** - Next by Date:
**Re: st: loop** - Previous by thread:
**st: rescaling a variable by the maximum value question** - Next by thread:
**Re: st: rescaling a variable by the maximum value question** - Index(es):