Statalist


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

Re: st: RE: limiting rows in tabulate


From   Richard Goldstein <richgold@ix.netcom.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: limiting rows in tabulate
Date   Mon, 17 Aug 2009 13:24:33 -0400

worked great -- thank you very much

Rich

Howard Lempel wrote:
One method that should work:

sysuse auto
egen include = total(foreign==1 & price>10000), by(rep78)
tab rep78 if price>10000 & include>0

Hope this helps.
Howie

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Richard Goldstein
Sent: Monday, August 17, 2009 12:10 PM
To: statalist
Subject: st: limiting rows in tabulate

Hi:

I am still using version 10.1

the row variable is a string variable

I have sent a client the results of a tabulate command based on a couple
of "if"'s

My client now wants me to drop one of the if's and do a new tab but
ensure that only the same rows (values) appear in the tab -- that is, if
a row was previously eliminated by the -if- that is now being dropped,
that row should still be eliminated

an example might make this clearer; say I do:

. ta rep78 if foreign==1 & price>10000

      Repair |
Record 1978 |      Freq.     Percent        Cum.
------------+-----------------------------------
           5 |          1      100.00      100.00
------------+-----------------------------------
       Total |          1      100.00
r; t=0.00 9:05:11

I now want to drop the foreign=1 condition but still have a table that
only shows the row for rep78=5

actually what is wanted now is a crosstab where the column variable was the old -if- condition, but the rows are limited; e.g.,
. ta rep78 foreign if price>10000

     Repair |
     Record |       Car type
       1978 |  Domestic    Foreign |     Total
-----------+----------------------+----------
          2 |         1          0 |         1
          3 |         7          0 |         7
          5 |         0          1 |         1
-----------+----------------------+----------
      Total |         8          1 |         9

but of course I would only want the row for "5"; in my actual data, the requested table would have more than 100 rows so I can't use a simple -if-

Rich

*
*   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/

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index