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
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: RE: last variable in the dataset
Date
Sun, 14 Aug 2011 12:32:29 +0100
Kit is right that this is a frequently asked question. The point is
discussed at [U] 18.3.4 and in
SJ-8-4 pr0045 . . . . . . . . Stata tip 70: Beware the evaluating equal sign
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
Q4/08 SJ 8(4):586--587 (no commands)
tip explaining the pitfall of losing content in a macro
because of limits on the length of string expressions
Nick
On Sat, Aug 13, 2011 at 10:49 PM, Christopher Baum <[email protected]> wrote:
> <>
> 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.
*
* 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/