Statalist


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

Re: st: Tabulate command ordering


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Tabulate command ordering
Date   Wed, 18 Jun 2008 18:31:42 +0100 (BST)

What about this:

gen cols = cond(sex == 1,               ///
           cond(selfemploy == 1, 1, 2), ///
           cond(selfemploy == 1, 3, 4))

label define cols 1 "Male, self"        ///
                  2 "Male, notself"     ///
                  3 "Female, self"      ///
                  4 "Female, notself"

label value cols cols

tab age cols


-- Maarten

--- Leonor Saravia <lmisaravia@gmail.com> wrote:

> Dear Statalisters,
> 
> First IŽd like to thank Andrea Bennet and Austin Nichols, for the
> help
> in merging the different datasets that I'm already using. :)
> 
> I'm working with a database that has information for working people,
> male and female, in different ranges of age and I'd like Stata to
> count how many male (female) persons are in each interval of age and
> satisfy the condition of being a self-employed person. Until now, I'
> m
> doing this:
> 
> bysort age: egen indep_m = sum(selfemploy == 1 & sex == 1)
> tab inxed_m
> 
> bysort age: egen indep_f = sum(selfemploy == 1 & sex == 2)
> tab inxed_f
> 
> And the Stata output for this is:
> 
>   inxed_m |      Freq.     Percent        Cum.
> ------------+-----------------------------------
>           2 |         66        0.40        0.40
>          70 |      1,582        9.62       10.02
>         144 |      2,311       14.05       24.08
>         231 |      1,924       11.70       35.78
>         373 |      3,761       22.87       58.65
>         427 |      2,852       17.34       76.00
>         530 |      3,947       24.00      100.00
> ------------+-----------------------------------
>       Total |     16,443      100.00
> 
>     inxed_f |      Freq.     Percent        Cum.
> ------------+-----------------------------------
>           0 |         66        0.40        0.40
>          26 |      1,582        9.62       10.02
>          65 |      2,311       14.05       24.08
>          68 |      1,924       11.70       35.78
>         164 |      2,852       17.34       53.12
>         171 |      3,761       22.87       76.00
>         259 |      3,947       24.00      100.00
> ------------+-----------------------------------
> 
> 
> My problem is that when I tabulate the result variables (" indep_m"
> and "indep_f ") Stata brings the output of the number of persons in
> each age range in an ascending order, but I'd like to have the
> information ordered by the range of age (not by the number of persons
> satisfying the conditions), to know how many persons are working as
> independent in each range of age.
> 
> I'd appreciate very much your advice in this.
> 
> Thanks!
> 
> Leonor
> 
> *
> *   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/
> 


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index