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: egen and variabel list

From   Tomas Lind <>
To   "" <>
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")
. . . . . 

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?


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:

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