Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: rescale grouped variables


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: rescale grouped variables
Date   Thu, 31 Mar 2005 16:55:53 +0100

I don't think you need any special commands
for this. 

I assume there is some other variable 
in this other than -raceid-. It looks 
like -finpos-. 

So 

bysort raceid (finpos) : gen nfinpos = (_n - 1)/(_N - 1) - 0.5 

as (_n - 1)/(_N - 1) will scale to [0,1]. 

Nick 
[email protected] 

[email protected]
 
> I am having trouble creating the following variable. I am 
> sure it is quite
> easy just escaping me for the past two days.
> 
> I have 80k horse races with a finishing position ranging from 
> 1-2 to 1-18.
> I have normalized the finishing position using the following:
> 
> sort raceid
> by raceid: get nfinpos=_N
> replace nfinpos=finpos/nfinpos
> 
> I would like to have the normalized finishing position 
> rescaled to -.5 to
> .5.
> 
> I can not find a command that lets me do this and allows by.
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index