Statalist


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

Re: st: question about -levelsof-


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: question about -levelsof-
Date   Tue, 5 Aug 2008 11:20:54 -0400

the reason is probably:

sysuse auto
levelsof rep78, local(levs)
local nlev `:word count `levs''
display `nlev'

so returning nlev is redundant

Regards,
  Sergiy


On 8/5/08, Jeph Herrin <[email protected]> wrote:
>
> 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index