Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: table command

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: table command
Date   Fri, 18 Jun 2004 16:44:30 +0100

-table-'s main job is to produce tables, 
not resultssets; 
as you don't like what -replace- does, 
your main option is to reproduce 
what -table- does by other means, 

egen count1 = count(var1), by(state) 
egen count3 = count(var3), by(state) 
gen newvar = count1 / count3

Note that, necessarily, each value 
of these variables is repeated within 
groups of -state-. -egen, tag()- offers
one handle here. 

Alternatively, -egen-haters can drill
one level down and do it all as an 
exercise in -by:-, _n and _N. 

Note that Roger Newson's utilities 
do not offer a solution here, as they 
are firmly wedded to a data reduction 

[email protected] 

Rijo John
>  I am using a simple table command
> table state, c(n var1 n var2 n var3) row
> Now I want to use the result of this table for generating new 
> variables.
>  Say, gen newvar = N(var1)/N(var3). One way is using the 
> "replace" option
> with the table command. But that cuses the data in memory to 
> lose. And I
> will have  to insheet the data set again. With out that 
> option is there a way out?

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index