Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
re: st: RE: last variable in the dataset
From
Christopher Baum <[email protected]>
To
"[email protected]" <[email protected]>
Subject
re: st: RE: last variable in the dataset
Date
Sat, 13 Aug 2011 17:49:42 -0400
<>
des, varlist
local myvars=r(varlist)
dis "`myvars'"
This produces a macro with all variables names. You can then extract the last one.
However if there are too many variables this trick will not work.
This is a FAQ. The reason why it won't work with many variables is that you have used an equals sign in the local statement. That truncates the result to 244 bytes if it is longer than that. Do not use an equals sign in this context unless you are trying to do arithmetic.
Kit
Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html
*
* 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/