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 on April 23, and its replacement, is already up and running.

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

st: Min value of a variable and an error in for loop

From   Mayank Mishra <>
Subject   st: Min value of a variable and an error in for loop
Date   Sun, 26 Jun 2011 21:43:42 +0530

Hello all,

I need to find out the minimum value observation of a variable. I
tried the following loop to obtain it:

gen temp = val[1]                                // val is the
variable whose min value i intend to find
forvalues i=2/_N {
replace temp = val[`i'] if val[`i']<`temp[1]'
gen minval = `temp [1]'

the message i got was invalid syntax. Please tell me the problem with
this loop. I also tried

local temp

, instead of "gen temp" in first line, but got the same result.

Also, please tell me, if there is some other more efficient method to do this.

Thanks a lot.


*   For searches and help try:

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