Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: How to find the minimum and maximum values of a column?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: How to find the minimum and maximum values of a column?
Date   Tue, 20 Jun 2006 18:37:16 +0100

For "column" read "variable" throughout. 

For "STATA" read "Stata" throughout. 

The limits on matrix size are given in the help 
on -limits-. The limits you quote apply to Intercooled
Stata, but with Stata/SE and Stata/MP you can go
much bigger. 

But that is not relevant here. As Alex indicates, 
you can use -summarize- directly. 

So, for example, 

foreach v of var a b c d { 
	su `v', meanonly 
	gen st`v' = (`v' - r(min)) / (r(max) - r(min)) 
}

Also, see the results of 

findit std01 

for the same idea implemented otherwise. 

Nick 
[email protected] 

Alex Ogan
 
> There are several ways to do this.  -search min- and -search 
> max- would
> point you to them, although it wouldn't be immediately obvious which
> links to click on.  Anyway, here are two:
> 
> -summarize varname- will create scalars r(min) and r(max).
> 
> -egen min_varname = min(varname)- will create a new variable 
> containing
> the minimum across all observations.
 
Laura Flamand
 
> I am working in a program to estimate an index similar to the Index of
> Human Development (PNUD, various  years), and I need to find the
> maximum and minimum value of several variables across 2500
> observations, I will then use these values to normalize the variables.
> I know how to find min and max values across rows, but I cannot find a
> command to find these min and max values across columns, other than to
> transpose the data set with xpose, or to transform my data set into a
> matrix (but then I can only have a 800x800 matrix, right?)

*
*   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