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

Re: st: 64 bit Stata for the Mac /feature request

From   Christopher Intemann <>
Subject   Re: st: 64 bit Stata for the Mac /feature request
Date   Tue, 17 Jun 2008 11:29:18 +0200

Hello Daniel
Am Jun 16, 2008 um 7:20 PM schrieb Daniel Stegmueller:


communicating with Stata from ESS is quite easy using applescript.

This is what I have in my .emacs file. It creates an (invisible) file in your user folder containing your selected code which is subsequently run by Stata.
Just assign a key to the function (I use F4) and the whole process becomes quite convenient...


(defun ado-to-Stata ()
(clipboard-kill-ring-save (point) (mark))
(do-applescript "try \r tell application \"Finder\" \r set TmpDo to (((path to home folder) as text) & \"\") \r set theContents to the clipboard \r if not (the last character of theContents = return) then \r set theContents to theContents & return \r end if \r end tell \r try \r set the open_target_file to open for access file TmpDo with write permission \r set eof of the open_target_file to 0 \r write theContents to the open_target_file starting at eof \r close access the open_target_file \r on error \r try \r close access file TmpDo \r end try \r end try \r tell application \"StataSE\" \r activate \r open file TmpDo \r end tell \r on error error_message number error_number \r return \"Error: \" & error_number & \". \" & error_message & return \r end try"))

P.S.: The "tell application \"StataSE\" \r activate" part brings up StataSE. You may need to adjust it.

Thank you very much. This does exactly what I was looking for.

If Stata Corp. would now change the results window in the next release/patch to support area selection, I'd be totally satisfied:-)


Hello to all,
thank you very much for all your comments about do-file/ texteditors.
I wasn't aware that stata is capable to handle apple events.
As I'm not familiar with apple script - is there a good ressource explaining how to use apple events
with emacs (or any other external editor)?
Regarding emacs, I'm currently using the ESS extension ( ), which does not
offer stata interoperability. Or, at least I coudn't figure out how to use it.
The ado-mode page ( ), which is linked
from, seems to have disappeared.
Is it mirrored somewhere?

However, this is not the only issue to solve.
The other thing is the exporting/ extraction of results.
Most OS X applications support the "Alt"-key when marking text.
For instance, with "Unphased", which is running in, it is possible to mark a distict
area of the text, like an individual column, an copy&paste it.
I REALLY miss this functionality in the stata results window, and I would like to strongly encourage the Stata
developers to include it in their next release.

Am 15.06.2008 um 15:36 schrieb Phil Schumm:

On Jun 14, 2008, at 11:18 AM, Christopher Intemann wrote:
For instance, I'm writing my scripts using emacs in stata mode. However, there is no way to run them (or parts from them) directly from emacs. It would be nice if the upcomming stata release would offer an interface for external editors.

If all you want to do is to run the file you're editing (or selected portions of it) in Stata, then you can use an "Open" Apple Event to do this. For more information, see the section on Macintosh editors in . I'm not an emacs user, but IIRC, it has a "do-applescript" command that you can use for this; I thought it had been incorporated into Bill Rising's Stata mode for emacs, but perhaps not. I have used this approach with AlphaX (and now TextMate) and it works quite well.

In fact, with the OS X executable update dated 25feb2008, this approach now works even better. Prior to that, when Stata had finished processing a file it would notify you via OS X's notification system (i.e., bouncing icon in the dock), and wouldn't accept any further requests until you had responded to the notification by switching focus to Stata. After the update, Stata no longer waits to accept new requests, and there is a preference item so that you can disable notification all together. These changes make working with external editors on OS X much nicer.

The question of whether StataCorp should add features to its do- file editor has been addressed several times before on the list. As several have noted, many of the users who find it inadequate would also find inadequate any editor except their preferred one. These users want to be able to use the same text editor for everything (e.g., data-analytic work, coding, writing, etc.), and have invested considerable effort in learning how to use their text editor efficiently and/or customizing it to suit their needs. StataCorp may decide to add features to their do-file editor in the future (since, clearly, there are a lot of users who use it), however my suggestion would be to take your preferred editor and figure out how to use it well with Stata; that way, you'll be happy whatever StataCorp does.

-- Phil

* For searches and help try:
*   For searches and help try:
Daniel Stegmueller
Landgrafenstr. 14
60486 Frankfurt a.M.

*   For searches and help try:
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index