Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: st: RE: last variable in the dataset

From   Christopher Baum <>
To   "" <>
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 Baum   |   Boston College Economics & DIW Berlin   |
                              An Introduction to Stata Programming  |
   An Introduction to Modern Econometrics Using Stata  |

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index