Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Re: troubles with ESS and STATA


From   Neil Shephard <[email protected]>
To   [email protected]
Subject   st: Re: troubles with ESS and STATA
Date   Wed, 23 Mar 2011 09:57:46 +0000

Francesco emailed me privately but I am responding to the list so that
the solution is available to all (as is the general etiquette and
guiding principles in the Statalist FAQ)....

On Tue, Mar 22, 2011 at 10:48 PM, Francesco Sarracino
<[email protected]> wrote:
> Dear Mr. Shephard,
> I'm writing you because of a nasty problem with Stata and Emacs: after some
> years of stata do-file editing with stata built-in editor I finally decided
> to move to a better editor and after long consideration I chose Emacs. Now I
> am able to edit my do files, but no way I can pass them directly from Emacs
> to Stata. I tried both the ado-mode by Bill Rising and more recently I tried
> with ESS (that I already know thanks to R). I got almost desperate since
> everywhere I found only bad news: nobody is able to run do files from Emacs
> directly in Stata using Linux (Ubuntu).
> Finally, I found a post by you at the following
> page: http://www.stata.com/statalist/archive/2010-10/msg00781.html
> where you state "Under GNU/Linux I can invoke the terminal version of Stata
> from within Emacs/ESS and send lines of code to the buffer"
> Do you have any clue on how to solve my problems? it would be of incredibly
> great help for me!

Firstly this concerns running Stata and Emacs/ESS under GNU/Linux (but
is likely generaliseable to other *NIX based systems).

I ensure that the path to the directory is present in the $PATH
environment variable by adding the following line to my ~/.bashrc (I
also add my local ~/bin/ directory where I have a few scripts, you may
or may not wish to include this)...

<--- ~/.bashrc --->
# Additions to system PATH
PATH="~/bin/:$PATH:/usr/local/stata/"
export PATH
<---------------------->

This means that when I type 'xstata' at a command terminal it starts
up the Stata GUI, or if I type 'stata' it invokes and starts the
terminal version of Stata within that terminal.

Once thats set up and running Emacs/ESS should automatically be able
to find the terminal version so after firing up Emacs simply use the
key-sequence

M-x stata

...to invoke Stata.  You will be asked which starting data directory
you wish to start Stata under and off you go.  You can now highlight
sections of your do-file in the editing buffer and use the usual
key-strokes to send it to the Stata buffer that is running.

I should point out that I rarely actually work this way unless I'm
running things on a remote server over ssh.  If I've a section of a
do-file I wish to run I normally have Stata GUI (xstata) running on
one desktop and emacs/ess with my do-file on another desktop, I'll
highlight the section of the do-file I wish to run, flip to xstata and
use the middle button (mouse wheel if you have one or both left &
right mouse buttons if not) to paste the code I highlighted into the
Command window and hit return to run.  Otherwise I just run the whole
do file with -do foo/bar-.

Hope that helps,

Neil


-- 
“Truth in science can be defined as the working hypothesis best suited
to open the way to the next better one.” - Konrad Lorenz

Email - [email protected]
Website - http://kimura.no-ip.org/
Photos - http://www.flickr.com/photos/slackline/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index