Statalist The Stata Listserver


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

Re: st: Tabout


From   Ian Watson <[email protected]>
To   [email protected]
Subject   Re: st: Tabout
Date   Wed, 23 May 2007 08:03:02 +1000

Ana

In a practical sense, you can still get SE without actually having real
survey data by just "pretending" you have survey data.

 sysuse auto
(1978 Automobile Data)

 gen wt = 1

 svyset [pw=wt]

       pweight: wt
           VCE: linearized
      Strata 1: <one>
          SU 1: <observations>
         FPC 1: <zero>

 tabout foreign using myfile.txt,  rep c(mean price se price) svy sum
layout(row)
Survey results being calculated
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
.........
Table output written to: myfile.txt

Car type
Domestic Mean   6,072.4
SE      (428.2)
Foreign Mean    6,384.7
SE      (549.9)
Total Mean      6,165.3
SE      (342.9)


(If you don't want the SE below the means, just omit the layout(row)
option.)


Perhaps someone on the list might comment about why these results (which
are based on -tabout- using the following command: svy: mean price,
over(foreign) ) differ slightly from using Stata's -ci- command with bys.

 bys foreign: ci price

-------------------------------------------------------------------------
-> foreign = Domestic

     Variable |        Obs        Mean    Std. Err.       [95% Conf.
Interval]
-------------+---------------------------------------------------------------
        price |         52    6072.423    429.4911        5210.184
6934.662

-----------------------------------------------------------------------------
-> foreign = Foreign

     Variable |        Obs        Mean    Std. Err.       [95% Conf.
Interval]
-------------+---------------------------------------------------------------
        price |         22    6384.682    558.9942         5222.19
7547.174


I note that without using the bys prefix, the results are identical:

 ci price

     Variable |        Obs        Mean    Std. Err.       [95% Conf.
Interval]
-------------+---------------------------------------------------------------
        price |         74    6165.257    342.8719        5481.914
6848.6



Cheers
Ian


PS I'm also copying this to you directly, since my replies to the
Statalist can sometimes take 12hrs to arrive.


Ana R. Rios wrote:
Ian,

Thank you for your suggestions.

Adding c:\ before the file name solved the file
locking problem. That is,

tabout location gender using c:\results.txt,replace

I have been reading the "tabout" manual and I
understand that Summary with SE or CI can only be
created for svyset data.  Please let me know if there
is a way to create a Summary with SE without the
survey option.

Thanks,

Ana Rios


--- Ian Watson <[email protected]> wrote:

Dear Ana

The problem you face occurs because of how Mata
sometimes locks files.
The other most common problem with locking files is
due to having the
text file open in an application like Excel when you
are outputing from
Stata (that's the reason for the error message
saying what it does).

The code below (between the snip marks) will solve
this problem. Cut and
paste it into an editor, and save it as
closeallfiles.ado in your
personal ado directory.

Next time you get a problem with file locking, just
type:

closeallfiles

at the Stata command line.


Regards

Ian



snip===========

program closeallfiles
 	 version 9

 	 forvalues i=0(1)50 {
 		    capture mata: fclose(`i')
 	 }
end

snip===========

Rios Galvez, Ana R wrote:
I am trying to use the "tabout" command and I am
getting the following error
messages:

tabout location gender using results.txt,
(note: file results.txt not found)
file results.txt could not be opened
                 fopen():   603  file could not be
opened
             write_tab():     -  function returned
error
               wrap_up():     -  function returned
error
             do_output():     -  function returned
error
                 <istmt>:     -  function returned
error
r(603);




tabout location gender using results.txt,replace

File results.txt
is already open inside another application.
Please close it before running tabout.


I do not have any file named "results". I have
tried with several different
file names and I am still getting the same error
message.
Could someone please help?

Thanks,

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




____________________________________________________________________________________Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/
*
*   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