[ESS] Enter Stata pound sign thingies?
Ista Zahn
istazahn at gmail.com
Tue May 20 15:42:27 CEST 2014
Hi Paul,
The ESS mechanism for running Stata code appears to be equivalent to
entering that code in the command box and hitting enter. Changing the
delimiter in that context doesn't work, as described in the stata
documentation here: http://www.stata.com/manuals13/pdelimit.pdf .
What stata appears to do when you highlight a section of code and "do"
it is to copy the highlighted code to a temporary file and "do" that
temporary file. Since emacs is programmable, you can implement this
strategy easily enough. One way to go is to compose a macro using "C-x
(", copy the selected region, save it to a file, switch to the stata
console and run "do <path/to/tmpfile". If you know a little elisp you
can write a function rather than record a macro, but the macro
approach will work and is easy even if you don't know elisp.
Best,
Ista
On Mon, May 19, 2014 at 3:49 PM, Paul Johnson <pauljohn32 at gmail.com> wrote:
> My RA wrote stata code like this, which temporarily declares the line
> terminator to ; because there is a weird funny business about stata
> and the deliminter.
>
> #delim ;
> local KeepVar "STU_ID SCH_ID G10COHRT F3D34 F3BYPNLWT byrace bysex
> F1RGPP2 byurban byregion
> bysibhom byincome bypared F2NAPAID F2PS1OUT F2HHPAR F2B25A F2B25D
> F2C38 F3D33 F2B28R F3PSLCTR F3STLOANEVR F3STLOANAMT BYP83A BYP84
> F3STLOANPAY F3D35 F3D30 F3D31 F3D27 F3D28B F3D28C F3D27 F3D29
> F3ERN2011 F3ATTAINMENT F3EDSTAT F3EVR4YR F3EVR2YR F1A19A BYA14E
> BYA23K F1S52B F1S52A F2B04";
> #delim cr
>
> Inside Stata itself, I can highlight that stanza and run it, but
> inside Emacs/ESS, there seems to be no way to do it. Highlight the
> whole thing, try to run the region:
>
> . #delim ;
> Unknown #command
>
> . local KeepVar "STU_ID SCH_ID G10COHRT F3D34 F3BYPNLWT byrace bysex F1RGPP2 by
>> urban byregion
> invalid syntax
> r(198);
>
> . bysibhom byincome bypared F2NAPAID F2PS1OUT F2HHPAR F2B25A F2B25D
> unrecognized command: bysibhom
> r(199);
>
> . F2C38 F3D33 F2B28R F3PSLCTR F3STLOANEVR F3STLOANAMT BYP83A BYP84
> unrecognized command: F2C38
> r(199);
>
> . F3STLOANPAY F3D35 F3D30 F3D31 F3D27 F3D28B F3D28C F3D27 F3D29
> unrecognized command: F3STLOANPAY
> r(199);
>
> . F3ERN2011 F3ATTAINMENT F3EDSTAT F3EVR4YR F3EVR2YR F1A19A BYA14E
> unrecognized command: F3ERN2011
> r(199);
>
> . BYA23K F1S52B F1S52A F2B04";
> unrecognized command: BYA23K
> r(199);
>
> . #delim cr
> Unknown #command
>
>
> Otherwise, I think the Emacs/ESS support for stata works well, the
> color highlighting is great and the run line-by-line parts work fine,
> except when they are the # thingies.
>
> Suggestions?
>
> pj
>
> --
> Paul E. Johnson
> Professor, Political Science Assoc. Director
> 1541 Lilac Lane, Room 504 Center for Research Methods
> University of Kansas University of Kansas
> http://pj.freefaculty.org http://quant.ku.edu
>
> ______________________________________________
> ESS-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
More information about the ESS-help
mailing list