Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Tomas Lind <Tomas.Lind@ki.se> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | st: egen and variabel list |
Date | Mon, 2 Jul 2012 13:34:44 +0000 |
Dear Statalist, I´m trying to calculate the maximum value from 17 variables with these variable names (where "O3" is ozone") O3_0_7 O3_1_8 O3_2_9 O3_3_10. . . . . . O3_16_23 As I may later on want to expand the range of the ozone variables it would be nice if I could use a local macro to generate the variable names. It seems to work fine (the display statement works) but none of the two -egen rowmax- works. You see the error messages after the //. I´m using Stata 11 under Windows. Has anyone a solution to this? /Tomas local var = O3_0_7 forval i= 0(1)16 { local j = `i'+7 local var "`var' O3_`i'_`j'" } di "`var'" // O3_0_7 O3_1_8 O3_2_9 O3_3_10 . . . . . O3_16_23 (Total 17 variables) egen O3max = rowmax(`var') // invalid name egen O3max = rowmax("`var'") // factor variables and time-series operators not allowed * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/