Statalist


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

Re: st: help needed with creating table


From   "Tom Trikalinos" <[email protected]>
To   [email protected]
Subject   Re: st: help needed with creating table
Date   Wed, 12 Mar 2008 16:04:02 -0400

help _tabstat_ ?



On Wed, Mar 12, 2008 at 3:35 PM, Lili Yan <[email protected]> wrote:
> Dear Statalist subscribers,
>
>  I need help to create a descriptive statistics table for a bunch of
>  -summarize- commands. Eventually, I want the table looks like this:
>
>                  Native cars          Foreign cars
>  var1             mean                       mean
>                   (sd)                           (sd)
>  var2             mean                       mean
>                   (sd)                           (sd)
>  No.of Obs.    xxx                           xxx
>
>  I tried some codes which I attached below. However, there are two
>  difficulities that I cannot solve. First, I want the same number of
>  observations for all variables. That is, only when an observation has
>  no missing values for all variables in the varlist, that observation
>  can be included in the sample. In my codes, each variable has its own
>  no. of obs.; Second, I want the standard deviation to be put below the
>  mean and in parentheses. Currently, it is beside the mean which is not
>  desired.
>
>  ...............tentative codes start here........
>  #delimit;
>  sysuse auto, clear;
>  global varlist mpg price weight length;
>
>  foreach var in $varlist { ;
>  qui summ `var' if foreign==1;
>  scalar drop _all;
>
>  mat drop _all;
>  mat n=r(N);
>  mat mean=r(mean);
>  mat v=r(sd);
>
>  mat input try=(0 0 0);
>  mat rownames try=`var';
>  mat colnames try= nbobs nbmean nbsd;
>  mat try[1,1]=n;
>  mat try[1,2]=mean;
>  mat try[1,3]=v;
>
>  mat list try;
>  };
>  ..................tentative codes end.................
>
>  Please kindly give some help! Thanks a lot!!
>
>  Best,
>
>  *
>  *   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/
>
*
*   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