I have declared a local macro that corresponds to several variable names in my Stata project:
local letters a b c d
I want to be able to generate a new variable using all variables in the macro letters
:
gen highest_letter = max(`letters')
However, this doesn't work, and leads to the following error message:
a b c d not found
This is because max()
requires that the input to be separated by commas like:
gen highest_letter = max(a, b, c, d)
Is there any way for me to manipulate the macro letters
?
Or use a function other than max()
, such that I can find the highest value in the list of variables without manually typing them into the max()
function?