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]

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–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index