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]

st: counting number of variables in a varlist


From   "ali hashemi" <hashemi@vt.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: counting number of variables in a varlist
Date   Wed, 15 Jun 2011 17:59:42 -0400

Dear list members,

I would like to count the number of variables in a varlist. The way I manage
to do this is as follows:

local i=0
foreach var in x1 x2 {
local i=`i'+1
}

I was wondering if there is any built-in command which does the same thing.

Any help is much appreciated
Ali

*
*   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