I use tabout to produce output tables in Stata 14. I want to drop the last two columns of my table. The handbook states that this can be done using the dropc() option.
This is my code:
tabout var_one var_two if year==2014 using table1.xlsx, ///
cells(freq col) format(0 2p) clab(N %) dropc(5 6) ptotal(none) replace
When I run this I get the following error message:
option dropc() not allowed
The code works fine if I remove the dropc() option. There isn't anything in the handbook that suggests why this is happening and a google search has turned up nothing.
You are using version 2 of the community-contributed command tabout, which is available on SSC.
The aforementioned error arises because option dropc() only works in version 3 beta.
You need to manually install this newer version by downloading the following file from the author's website into your adopath (click here for more information):
http://tabout.net.au/downloads/main_version/tabout.txt
You should also rename the extension to tabout.ado. Note that this is the file for Stata 14 and later.
Once installed, the dropc() option will work:
sysuse auto, clear
tabout mpg price if foreign == 1 using table1.txt, ///
cells(freq col) format(0 2p) dropc(5 6) clab(N %) ptotal(none) replace
Related
I'm running a long list of regressions in Stata. Results are exported using outreg2. At random points in time, the execution stops at some outreg2 with the error file handle __00000G not found. When I rerun the whole exercise it works after some tries. Do you have any idea what could be the reason?
My code looks as follows where further regressions of the same type follow.
xtreg l_GDP_capita i.year date_intens, fe r
outreg2 using year_DG_FE_gdp, excel append label addtext(DG FE, YES, YEAR FEs, YES) drop(i.year) ctitle(log GDP per capita, AP) replace
xtreg l_GDP_capita i.year date_intens if any_lez==1, fe r
outreg2 using year_DG_FE_gdp, excel append label addtext(DG FE, YES, YEAR FEs, YES) drop(i.year) ctitle(log GDP per capita, LEZ)
Two thoughts:
(1) your file name needs to be in quotations, so outreg2 using "year_DG_FE_gdp", [blah] instead of outreg2 using year_DG_FE_gdp, [blah].
(2) In case you haven't done so, you need to set a directory. cd "whatever filepath you want to save to" (or a global directory if you want to get fancy). You may have done this earlier in your code (I usually do it at the top of a .do file), but since you've only posted the snippet here I can't tell. Forgetting it is one of the classic problems people tend to have with outreg.
Not 100% sure, but I am having the same problem and I think this may arise when outreg2 is writing to a directory that is being synced (e.g. Dropbox, Google Drive). I believe the conflict may come from a permissions conflict where Stata is trying to change the file as the sync software is uploading the change. If you can pause the syncing of the directory while running the Stata commands, this seemed to help me.
The eq5d command in Stata computes an index value from individual responses to the EQ-5D quality-of-life instrument, as it is described here http://www.stata-journal.com/article.html?article=st0220
But the eq5d command is not recognized by Stata 12.1 for Windows (32 bits) installed in my laptop. Is it a version issue? Or is there a change in the command name?
Does someone have any idea how to get the eq5d command working in Stata 12?
It is not a version problem as the minimum requirement of eq5d is Stata 9, so version 12 is fine. However, it is a user-written command, so you will need to install it. To do so, type in Stata findit eq5d; after that it is just a matter of clicking on the appropriate links.
I have been using the estout commands for quite some time now, but am now working on a couple of computers that are not connected to the internet. I have been getting the following error from the esttab command:
current estimation results do not have e(b) and e(V)
To test this with a simpler example, I tried to replicate the example here: http://repec.org/bocode/e/estout/estpost.html#estpost101
I created a sample dataset as below:
price mpg rep78 foreign
1 3 1 1
2 3 1 1
3 3 1 2
4 3 2 3
5 3 2 5
6 3 2 8
7 3 3 13
8 3 3 21
9 3 3 34
And then ran the following commands as per the example:
estpost summarize price mpg rep78 foreign, listwise
esttab, cells("mean sd min max") nomtitle nonumber
I got the expected output with the estpost command, but got the aforementioned error when running esttab. I have uninstalled and reinstalled this package several times, using both a version downloaded onto another computer using ssc install and a version downloaded from http://repec.org/bocode/e/estout/installation.html. I feel that I must be missing something obvious...any help would be appreciated.
EDIT: I just checked with a colleague of mine, and it seems they have been inexplicably getting the same error recently.
This works for me. I suspect faulty installation. Despite your best efforts, you may have previously installed versions of some or all of the programs in estout on your system.
In Stata, you need to check what Stata is seeing by typing commands such as
. which esttab, all
in every directory in which you work. If necessary, repeat for all the other command files in the package as named by ssc desc estout. You should be seeing one (and only one) version of each command, dates mostly in 2009 (eststo in 2008).
A wilder hypothesis is that estout has been broken by recent changes in Stata. This seems unlikely to me, but check the above first.
(UPDATE) OP reply reveals a nightmare scenario: old versions have been found that are difficult to remove. What to do?
Look at the adopath command. In the first instance, just type adopath. Stata wants to install estout stuff in an e off whatever it labels PLUS. (If you are in the US, you probably want to say "off of".)
One possibility is that you use adopath to reset PLUS to somewhere you have write access, preferably somewhere dedicated to programs alone. That's got implications for programs already in PLUS, which are now longer visible, so you need to add whatever is now PLUS as an extra place to look. The help for adopath explains how to do this.
Another possibility is that Stata always looks in the current directory or folder for a user-written program before it looks in PLUS (unless you mess with that order, which I advise against). So, so long as programs you want are in the current directory, that should work. However, this would usually be considered poor style. Worse, as you change the working directory, you need to copy programs to that directory.
You may need to approach the administrators to delete the old stuff. It is hard to work with user-written programs for Stata if you don't have the right privileges.
Here is a sample program .do file, sampleprog.do:
program sampleprog
egen newVar = group (`1' `2')
end
How can I post it on my website (or dropbox), so that other people could install it to their Stata like this?
net from http://www.mywebsite.com/sampleprog.do
*** or may be like like this:
ssc install ...
I read the documentation about stata.toc...but I did not quite get it. What files should I upload and should it be one folder or what?
(PS: I definitely can simply email the .do file but this is not an option in my case.)
Here is a full explanation of how to share program or data files with others using your own website. I tried using Dropbox, but Stata 12 appears to have issues with https, which is the protocol for all Dropbox public links. If you want to use Dropbox, I recommend creating a shared folder that will sync on your collaborators' machines. The rest of this answer assumes you have a website serving pages over http or are using Stata 13, which supports https.
If this is a one-time thing, you can skip the rest of this answer by putting the file on your website and telling your collaborator to type:
. copy http://your-site.com/ado/program.ado program.ado
That will copy the ado file at the specified url into the user's current directory. If you want to provide information about your files, plan on sharing with multiple people and need to maintain/document a set files, read on!
Step 1 Create a folder on your website to hold the programs. I will call mine ado/
Step 2 Add the program files, help files, and data files you want to share. For this example, I have created a simple ado file called unique.ado with the following contents:
********************************************** unique.ado
capture program drop unique
program define unique
*! Count and number observations within group defined by varlist
* Example: unique person_id, obs(prow) tobs(pcount) sortby(time)
* to count and number rows by a variable called person_id
syntax varlist, obs(name) tobs(name) [sortby(varlist)]
bys `varlist' (`sortby') : gen long `obs' = _n
bys `varlist' (`sortby') : gen long `tobs' = _N
la var `obs' "Number of this row within `varlist' group."
la var `tobs' "Total number of rows with identical `varlist' values."
end
Step 3 Create a file called stata.toc to describe the files you wish to share. Here is mine:
********************************************** stata.toc
v 3
d Program to count observations by group
p unique [The unique.ado program for counting observations by group]
These files can be complicated. There are many features I won't cover here, but you can read this documentation to learn more.
Step 4 Create a package file for each of the packages defined by the lines in stata.toc that start with the letter p. Here is my package file for the unique package defined above:
********************************************** unique.pkg
v 3
d unique
d Program to count observations by group
d Distribution-Date: 28 June 2012
f unique.ado
Your directory now looks like this:
ado/
stata.toc
unique.ado
unique.pkg
Step 5 Use the site! Here are the commands to enter.
. net from http://example.com/ado/
. net describe unique
. net install unique
Here is what you'll see after entering the first command:
-----------------------------------------------------------------------------------
http://www.example.com/ado/
Program to count observations by group
-----------------------------------------------------------------------------------
PACKAGES you could -net describe-:
unique [The unique.ado program for counting observations by group]
-----------------------------------------------------------------------------------
The second command will tell you more about the package net describe unique:
---------------------------------------------------------------------------------------
package unique from http://www.example.com/ado
---------------------------------------------------------------------------------------
TITLE
unique
DESCRIPTION/AUTHOR(S)
Program to count observations by group
Distribution-Date: 28 June 2012
INSTALLATION FILES (type net install unique)
unique.ado
---------------------------------------------------------------------------------------
The third command will install the package net install unique:
checking unique consistency and verifying not already installed...
installing into /Users/cpoliquin/Library/Application Support/Stata/ado/plus/...
installation complete.
EDIT
See Nick's comments in the answer below. I intended this example to be simple and I don't expect other people to use this program. If you plan on submitting things to Stata Journal or SSC then his comments certainly apply! I hope this answer can serve as a decent tutorial for those confused by the official documentation.
This will be too long for a comment, so it is going to be an extra answer.
Your example uses the program name unique. If you search unique, all (or in Stata 13, search unique) you will find that a user-written program with the same name has been installed on SSC since 1998. This will create a clash of names for your users if (and only if) they attempt to use your program and also that earlier program. The more general advice is to search to see if a program name is already in use to try to avoid these problems.
Specifically, although you may just be using your unique as an arbitrary example, note that it contains bugs. An int doesn't contain enough bits to hold observation numbers exactly for large datasets. Also, as a matter of style, unique can change the sort order of your data, which is widely considered to be poor data management style.
Your example concerns dissemination of a program file without an accompanying help file. Suffice it to say that the SSC site would never accept such a program and the Stata Journal would not even review a paper based on such a submission before a help file was written to accompany it. Including explanatory comments with the code may be sufficient for your personal practices, but it falls below general Stata standards.
Stata 13 now supports https. See http://www.stata.com/manuals13/u.pdf, Section 3.6.
In short, I appreciate that you are trying to explain how to do something, but it is already well documented, and explicitly and implicitly some of your recommendations are below community standards.
This question already has an answer here:
How to export Spearman correlations
(1 answer)
Closed 3 years ago.
I need to get a Spearman and Pearson correlation table using Stata. Here is what I did to get the results in a table format.
estpost correlate sp_rating srating mrating split split_neg split_ord split_neg_ord tier1_risk tier1_leverage st1 sl mt1 ml adt1 adl dt1 dl offering_amt maturity2 security
enhance timeliness validity disc loan_at cash_dep trading_at real_est intangible other_at sec_sum assets_sold all_residual secinc_ta, matrix quietly
esttab . using "root4.rtf", replace notype unstack compress noobs nogaps nostar
Then, I get this error message:
varlist not allowed
When I used just a few variables, I didn't get the error, but when I put many variables. I don't know how to fix this. Please help me.
I was able to reproduce your error and ran a trace on it. I believe this is a bug at line 946 of estout.ado, perhaps caused by the fact that a very long variable list with RTF tags exceeds the size of the local macro created at that line.
You should send a bug report to Ben Jann (email at the end of help estout). In the meantime, you can try saving to DOC and TXT, both of them might work (you have over 30 variables, I tested both .txt and .doc successfully with something like 20 variables).
Alternately, try the mkcorr command (ssc install mkcorr) to see if it works with your data.
I just had the same problem after I tried a lot of different esttab outputs and had stored a lot in estimates.
So, maybe estimates clear helps if you type it before running your command. At least for me it worked.