The notepad button opens a new do file
However, I'll suggest that you use an external text editor instead of the built-in text editor.
I'm not a snob about this. I still use the menus for many commands, especially new ones I'm not familiar with. However, eventually you'll have to write long files to:
Using a text editor is easier for the following reasons:
- Text editors make search-and-replace easier if you make a systematic mistake
- Text editors allow you to have Stata closed while writing
- Text editors (at least the ones outlined here) highlight syntax, which is invaluable for checking your code
- Text editors just have more options than the built-in editor (keyboard shortcuts, multiple views, ready-made templates)
- Text editors, as the name might suggest, make editing existing .do and .dct files much easier
As far as available editors for Mac, there are many. Look around VersionTracker and you'll find all sorts of free or cheap options, like SubEthaEdit, TextWrangler, Smultron, Vim, and lots of others.
If you're willing to pay a bit more, there are very full-featured programs like BBEdit ($49 US educational, $125 otherwise) and TextMate (39 Euros). Although these are impressive, they are geared much more towards professional web developers and are, in my opinion, a bit of overkill for Stata.
I can't say I've tried all of these, of course. But I've experimented with a number of editors, including the built-in TextEdit, Taco Edit, Aquamacs, Smultron and TextWrangler.
Unlike some built-in OS X software, TextEdit isn't too impressive. There are far better choices for free.
Taco Edit is really designed for HTML coding, not other languages.
Aquamacs is pretty good, some people really swear by it, including many of the skilled and serious programmers I know. The main objection I had was that it was much more difficult to integrate with Stata. You need to install a series of .ado files into Stata to make Aquamacs work as an external editor. Read this if you're interested.
I haven't tried Vim.
So we're down to two contenders:
Smultron (open-source, freeware)
Smultron is nice. It has a pleasant Cocoa interface. It handles multiple open files easily. It doesn't take much memory. Here's a screenshot:
TextWrangler (non-open-source, freeware)
However, I'm going to recommend TextWrangler, the free version of BBEdit developed by Bare Bones Software. Here's what it looks like:
Most importantly, TextWrangler integrates extremely easily with Stata:
- Save a file with a .do extension, and TextWrangler will immediately recognize it as a file that should be formatted according to Stata syntax and run in Stata.app
- The defaults can be set so new files are always formatted as .do files
- Once you've saved a .do file, you can quickly run it in Stata like this:
Click the button on the right and the file will pop up in the Finder window:
Double-click the file in Finder and it will immediately run in Stata; if Stata is closed, it will immediately open it and run it.
And here's a really nice feature: at the bottom of TextWrangler, you can select your language and it will immediately recognize the command words. So if you need to do some website editing in CSS or HTML (as I sometimes do), TextWrangler is very helpful for that as well.
While you can't go wrong with either Smultron or TextWrangler, I'd recommend the latter as a free, full-featured, do-it-all program for Stata coding.
Next installment will deal with Step 4: Importing Unformatted Data
Technorati Tags:
Smultron, Stata, TextWrangler, Mac OS X, text editors, statistical software
6 comments:
I have BBEdit and it does not manage to handle .do files created in BBEdit the same way you say TextWrangler does. I'll try again...
Hi, I am glad I have found your blog as it seems to address also the problem I am trying to solve: finding an external editor that is fully integrated with Stata, including the ability to submit code. However, I do not seem to be able to find a reference. Am I mistaken or is this bit really missing? I have checked the excellent page by Nicholas J. Cox, but also there I am unable to find the answer. (Yes, I am using Text Wrangler too) Is there any? Thanks, Zsombor
Thanks for the tips. I'm considering turning to TextWrangler. Does it allow you to do or run only part of a .do file like STATA's built on editor does?
Hi everyone. I'm afraid "integration" is too strong a word here, my apologies. Several people have emailed asking about scripting or sending snippets of code directly to Stata. I don't think this is possible with Textwrangler (please tell me if it is).
Textwrangler is still my preferred editor but code submission is limited to clicking the stata icon at the top of text wrangler to reveal the file in finder, then double-clicking in finder to run it.
Sorry for the misunderstanding. - Adam
A very helpful source for more TextWrangler to Stata material: http://dataninja.wordpress.com/2006/03/03/send-to-stata-applescript-for-textwrangler/
Thanks for sharing in detail. Your blog is an inspiration! Apart of really useful tips, it's just really ! This post will be effectively Just about everything looks good displayed.
_________________________
Mac Photo Editor
Post a Comment