Is there a way to access the maximum and minimum values stored in a numlist or local using something like min()
and max()
in Stata? I want to archive roughly something similar to this:
local test 5 10 25 50
local max_test = max(`test')
local min_test = min(`test')
foreach i in `test'{
qui gen x_`i' = `i'
}
reg y x_`min_test ' - x_`max_test '
The help for
max()
tells you that it accepts comma-separated arguments, so this will work:Naturally, you could put the commas in at the outset. Same story for the minimum.