Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • -describe- counts all variables in the file, not just in the varlist specified

    I just noticed something I didn't anticipate about how -describe- counts the variables in a varlist supplied to it. My apologies for the noise if this is well-known to most users.

    -describe- returns in r(k) the number of variables in the entire data set, not the number in the varlist fed to it. I didn't find any documentation that made this clear. It's not a big deal, of course, but the situation in which I encountered it is not a strange use-case: I did something like
    Code:
    describe ThisVar-ThatVar
    because I wanted to know the number of variables in the unabbreviated varlist without having to count them by hand. So, while there are other less convenient ways to get that count, -describe- won't help.

  • #2
    I did not know that. I just checked, this has been true at least for Stata 8 (the earliest Stata I have access to).

    I am sure you know, but maybe for other persons reading this thread: One way of doing this is:

    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . unab vars: m*
    
    . display `: word count `vars''
    2
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment

    Working...
    X