Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: RE: Followup: inverting a stored table of regression results - then exporting to a cvs/excel file


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: RE: RE: Followup: inverting a stored table of regression results - then exporting to a cvs/excel file
Date   Fri, 5 Nov 2010 18:50:43 +0000

Thanks for the mention, but 

1. The context is one in which the levels themselves are needed, so -levelsof- has been fired up already. 

2. If you are interested in -distinct-, please note that Gary Longton is a co-author of the program and also jointly responsible for 

SJ-8-4  dm0042  . . . . . . . . . . . .  Speaking Stata: Distinct observations
        (help distinct if installed)  . . . . . .  N. J. Cox and G. M. Longton
        Q4/08   SJ 8(4):557--568
        shows how to answer questions about distinct observations
        from first principles; provides a convenience command

which is the source to be looked at. 

Nick 
[email protected] 

David Radwin

You could also save a step and use Nick's -distinct-, available from SSC.


. distinct rep78

              |        Observations
     Variable |      total   distinct
--------------+----------------------
        rep78 |         69          5

. di `r(ndistinct)'
5

Nick Cox

> You just get Stata to count the levels.
> 
> . sysuse auto
> (1978 Automobile Data)
> 
> . levelsof rep78, local(levels)
> 1 2 3 4 5
> 
> . local nlevels : word count `levels'
> 
> . di `nlevels'
> 5
> 
> Nick
> [email protected]
> 
> Ben Hoen
> 
> Let's say I do not know how many groups I have delineated in -levelsof-,
> but
> needed to create code to break the table if necessary.
> 
> I figure, I want to create a local macro of the number of groups and
then
> I
> can create an if/then step as is needed.  I am sure one can do this, but
I
> was not able to figure it out.  Do you know how?


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index