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, statalist.org 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   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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 <kit.baum@bc.edu> 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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index