Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: question about -levelsof-


From   "Newson, Roger B" <r.newson@imperial.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: question about -levelsof-
Date   Tue, 5 Aug 2008 16:29:35 +0100

Possibly, the authors of levelsof thought it not worth the effort, as it
is trivial to add 1 extra line. As in

levelsof educ, local(educs)
local neduc: word count `educs'

or even as in

levelsof educ
local neduc: word count `r(levels)'

The extended function "word count" is described under

whelp extended_fcn

along with many others.

Roger


Roger B Newson
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: r.newson@imperial.ac.uk 
Web page: www.imperial.ac.uk/nhli/r.newson/
Departmental Web page:
http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/pop
genetics/reph/

Opinions expressed are those of the author, not of the institution.

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Jeph Herrin
Sent: 05 August 2008 15:00
To: statalist@hsphsun2.harvard.edu
Subject: st: question about -levelsof-


I find -levelsof- very useful, but a while back
decided it would be more useful if it also returned
the number of levels.

When I looked at the -ado- file, it seemed like
a trivial hack; the local macro -nvals- was already
there, so I just added

   return local nvals `nvals'

This seems to work, yet seems much too easy; but
looking through the code for a reason this
might sometimes fail, I couldn't find one.

So, my question is, is there a reason -levelsof-
doesn't return -nvals-? I use it so often, I worry
that maybe I'm setting myself up for disaster.

thanks,
Jeph
*
*   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/

*
*   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   |   What's new   |   Site index