Statalist


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

RE: st: RE: about the return list of -codebook-


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: about the return list of -codebook-
Date   Fri, 31 Aug 2007 00:39:41 +0100

You can do this and it would indeed be an instructive exercise. 

But yet another program hardly seems necessary for this 
problem when there are least six ways to do it already 
in existence, three of them documented in an FAQ. Here are
two more: 

1. 
egen tag = tag(mpg)
count if tag 

2. 
qui tab mpg 
di r(r) 

1. leaves a variable lying around, but it requires
no programming, and that variable has some uses. 
There are some limits on 2., but it is often practical. 

Nick 
[email protected] 

Sergiy Radyakin
 
> Alternatively one can find -CntUniq- inside codebook.ado, cut it and
> paste into CntUniq.ado. It requires 2 arguments, variable of interest
> and a touse marker 0/1.
> 
> sysuse auto
> gen marker=weight>4000
> CntUniq weight marker
> return list
> codebook weight
> 
> To understand, which result means what, compare with the 
> results from -codebook-
 
> On 8/30/07, Nick Cox <[email protected]> wrote:
> > If it did this, it would be (a) documented
> > and (b) evident from -return list- after
> > applying the command.
> >
> > -codebook- is an r-class command, but the r-class
> > results issued are restricted to problem reports.
> >
> > More positively, when you say "unique" values
> > I take it that you mean "distinct". Either way,
> >
> > . search unique, faq
> >
> > points to various ways of finding this out,
> > including dedicated programs. One that sticks
> > in my mind somehow is -distinct- from SSC by
> > Gary Longton and another. Also you could
> > do something like
> >
> > . levelsof mpg, local(levels)
> >
> > . di `: word count `levels''
> >
> > Nick
> > [email protected]
> >
> > Luhang Wang
> >
> > > Does anyone know whether Stata stores the number of unique values
> > > after command -codebook- in any built in macro, just like 
> r(mean) for
> > > mean after -sum-?

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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