Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: table formatting in stata


From   Sergiy Radyakin <serjradyakin@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: table formatting in stata
Date   Fri, 28 Jun 2013 00:34:05 -0400

Hi, I really want to help, but I am afraid I can't understand the
problem. Partially because it seems to me there is a part of the email
missing. Also, in Stata 'casewise' means observation as a whole, not
'individual variable' which I think you are confusing here. See here
for examples:
http://books.google.com/books?id=zCym0GtuRE4C&lpg=PA25&ots=i2igqfWYtu&pg=PA25#v=onepage&q&f=false

I have reproduced the output of the all 51s, and have modified it to
show 51 where appropriate in your example.

You can reinstall the package.

Best, Sergiy

On Thu, Jun 27, 2013 at 10:12 PM, Haluk Vahaboglu <vahabo@hotmail.com> wrote:
> Hi Sergiy,
> I would like to thank you again for the below code you provided and the ado "ttesttab".
> May I take your attention to the difference between outputs obtained by executing the code below and the "ttesttab" ado.
>
> The code you provided below returns "n" of variables correctly, which means this code treats missing values independently for each row (variable).
> But the ttesttab command treats missing values in a different way.
>
> sysuse auto, clear
> replace price = . in 1
>
> The code returns:
> price    51
> length    52
> weight    52
> headroom    52
>
> ttesttab returns:
> price    51
> length    51
> weight    51
> headroom    51
>
> I believe missing values should be treated case-wise as returned with the code. Could you help to fix this problem with the "ttestab" ado.
>
> Regards
>
>
>
>
>
>
>
>
>
>
> @page
> {;}
> .ExternalClass P
> {margin-bottom:0.08in;}
>
>
>
>
>
>
>
>
>
>
> @page
> {;}
> .ExternalClass P
> {margin-bottom:0.08in;}
>
>
>
> Prof. Dr. Haluk Vahaboğlu
> Istanbul Medeniyet
> Üniversitesi,
> Göztepe Eğitim ve Araştırma Hastanesi
> Enfeksiyon Hastalıkları
> ve Klinik Mikrobiyoloji ABD
> Dr. Erkin Caddesi  34730
> Kadıköy / Istanbul  TURKIYE
>
>
>
>> Date: Thu, 6 Jun 2013 18:38:57 -0400
>> Subject: Re: st: table formatting in stata
>> From: serjradyakin@gmail.com
>> To: statalist@hsphsun2.harvard.edu
>>
>> How about this? Sergiy
>>
>> sysuse auto, clear
>>
>> local vars "price length weight headroom"
>> local gvar "foreign"
>>
>>
>> local n=`:word count `vars''
>> matrix R=J(`n',7,.)
>> matrix list R
>>
>> forval i=1/`n' {
>>   local w `:word `i' of `vars''
>>   quietly ttest `w', by(`gvar')
>>   matrix R[`i',1]=r(N_1)
>>   matrix R[`i',2]=r(mu_1)
>>   matrix R[`i',3]=r(sd_1)
>>   matrix R[`i',4]=r(N_2)
>>   matrix R[`i',5]=r(mu_2)
>>   matrix R[`i',6]=r(sd_2)
>>   matrix R[`i',7]=r(p)
>> }
>>
>> matrix coleq R = " " "Group 1" " " " " "Group 2" " " " "
>> matrix colnames R = N mean SD N mean SD p
>> matrix rownames R = `vars'
>>
>> matrix list R , format(%4.3f)
>>
>> On Thu, Jun 6, 2013 at 6:18 PM, Haluk Vahaboglu <vahabo@hotmail.com> wrote:
>>> Sergiy,
>>> Thank you for your contribution.
>>> Unfortunately, tabstat do not generate a "p" value of T Test. I need n mean sd & "p" on a line.
>>> Therefore, neither tabstat not tabstatmat resolve this problem.
>>>
>>>
>>> Prof. Dr. Haluk Vahaboğlu
>>> Istanbul Medeniyet
>>> Üniversitesi,
>>> Göztepe Eğitim ve Araştırma Hastanesi
>>> Enfeksiyon Hastalıkları
>>> ve Klinik Mikrobiyoloji ABD
>>> Dr. Erkin Caddesi 34730
>>> Kadıköy / Istanbul TURKIYE
>>>
>>>
>>>
>>>
>>> ----------------------------------------
>>>> Date: Thu, 6 Jun 2013 16:13:32 -0400
>>>> Subject: Re: st: table formatting in stata
>>>> From: serjradyakin@gmail.com
>>>> To: statalist@hsphsun2.harvard.edu
>>>>
>>>> Yes, it is possible:
>>>>
>>>> sysuse auto,clear
>>>> tabtstat price weight length, stats(mean sd)
>>>>
>>>> If you need it transposed, (and I assume you do) then add an option
>>>> save to the above, then use Austin Nichols' -tabstatmat- to put
>>>> results into matrix and transpose it. Type:
>>>>
>>>> findit tabstatmat
>>>>
>>>> and follow instructions.
>>>>
>>>> Best, Sergiy
>>>>
>>>>
>>>> On Thu, Jun 6, 2013 at 5:11 AM, Haluk Vahaboglu <vahabo@hotmail.com> wrote:
>>>>> TD P { margin-bottom: 0in; }P { margin-bottom: 0.08in; }
>>>>>
>>>>>
>>>>> Hello Everybody,
>>>>> In our research papers we
>>>>> mostly present continuous data in a table with comparison to cases vs
>>>>> controls as "n mean SD and p (from Ttest)". Here is a brief
>>>>> example of such a table:
>>>>>
>>>>>
>>>>>
>>>>> ................Cases / Controls
>>>>> ........N mean (SD) N mean (SD)...p
>>>>> Var1
>>>>> Var2
>>>>>
>>>>>
>>>>>
>>>>> With STATA I use these
>>>>> commands
>>>>>
>>>>>
>>>>>
>>>>> 1. "estpost tabstat age
>>>>> VAR1 VAR2, by(C/C) s(n mean sd) c(s)"
>>>>> 2. "esttab ., main(mean)
>>>>> aux(sd) unstack noobs nonote wide compress label"
>>>>> 3. "estpost ttest age
>>>>> VAR1 VAR2, by(C/C) une w"
>>>>> 4. "esttab ., cell("p
>>>>> (fmt(3))")"
>>>>>
>>>>>
>>>>>
>>>>> and get two separate
>>>>> tables "n mean SD" in one and "p" in the other. I afterwards
>>>>> combine these two in one table formatted as mentioned above.
>>>>>
>>>>>
>>>>>
>>>>> Is there any simple way to
>>>>> get a table with n-mean-SD-p all in one line for multiple continuous
>>>>> variables?
>>>>> Thanks again
>>>>> note: sorry for the subject line of my previous message
>>>>>
>>>>> *
>>>>> * For searches and help try:
>>>>> * http://www.stata.com/help.cgi?search
>>>>> * http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index