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: Followup: inverting a stored table of regression results - then exporting to a cvs/excel file
From 
 
"David Radwin" <[email protected]> 
To 
 
<[email protected]> 
Subject 
 
st: RE: RE: Followup: inverting a stored table of regression results - then exporting to a cvs/excel file 
Date 
 
Fri, 5 Nov 2010 11:42:50 -0700 (PDT) 
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
David
--
David Radwin
Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794
www.mprinc.com
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Nick Cox
> Sent: Friday, November 05, 2010 10:30 AM
> To: '[email protected]'
> Subject: st: RE: Followup: inverting a stored table of regression
results
> - then exporting to a cvs/excel file
> 
> 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/