[ESS] ess and sas

Wilmar Igl wilmar.igl at gmx.de
Fri Nov 2 09:56:16 CET 2007


Dear Geoffrey,

as SAS under Windows does not support the -stdio flag you can only run 
SAS in Batch mode. (cf. ESS-Manual, Section 10.4
http://www.xemacs.org/Documentation/packages/html/ess_10.html#SEC58,
Section 10.9
http://www.xemacs.org/Documentation/packages/html/ess_10.html#SEC63
) Therefore you have to configure several ess-variables accordingly. 
Furthermore, there is at least one bug in the the ESS source 
(essa-sas.el, patch see below) which causes conflicts to run code and to 
view data sets in SAS Batch mode. Please look at the following lisp 
configuration that I have in my .emacs and adapt it to your pc environment:

(message " ")
(message 
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;")
(message ";; Extra: Statistics ")
(message 
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;")

(message ";; Emacs speaks Statistics (ESS)")

(require 'ess-site)

;; ESS: R-Mode

;; omitted

;; ESS: SAS-Mode

(require 'essa-sas)
(setq ess-sas-global-pc-keys t)

(setq-default ess-sas-submit-command "sas.exe -autoexec 
\"z:\\00_Preferences\\SAS\\autoexec_batch.sas\" -batch -pageno 1 -nosplash")
(setq-default ess-sas-submit-command-options "-sysin")
(setq-default ess-sas-data-view-submit-options "-nosysin -print NUL: 
-log NUL:")
(setq-default ess-sas-submit-method  'sh)

(defun ess-sas-3window ()
"Put running SAS buffers into three windows in one frame.
Place the cursor in a myfile.sas buffer.  Run SAS in Batch mode,
Return the cursor to the myfile.sas buffer, then enter C-c 3 to
put myfile.sas in the upperleft window, myfile.log in the
upperright window, and myfile.lst buffers in the bottom window.
The SAS Shell buffer remains buried."
   (interactive)
   (delete-other-windows)
   (split-window-vertically)
   (split-window-horizontally)
   (setq sas-file-name (buffer-name))
   (find-file (concat (substring sas-file-name 0 -4) '".sas"))
   (other-window 1)
   (find-file (concat (substring sas-file-name 0 -4) '"-temp.log"))
   (setq buffer-read-only t)
   (other-window 1)
   (find-file (concat (substring sas-file-name 0 -4) '"-temp.lst"))
   (setq buffer-read-only t)
   (other-window 1)
)

(add-hook 'sas-mode-hook
(global-auto-revert-mode t)
(setq ess-sas-temp-root "-temp")
)

(define-key ess-mode-map [(control ?c) (?3)]         'ess-sas-3window)
(define-key ess-mode-map [(control ?c) (control ?b)] 'ess-sas-submit)
(define-key ess-mode-map [(control ?c) (control ?r)] 'ess-sas-submit-region)

;;;;;;;;;;;;;;;;;;;;;;;;;STOP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Furthermore create a specific autoexec_batch.sas file which includes:

/********************autoexec_batch.sas****************************/

**  Output options for .lst files (in batch mode) **;
**  http://support.sas.com/rnd/web/intrnet/format/out/sasopts.html **;
OPTIONS FORMCHAR='|----|+|---+=|-/\<>*';

libname user 'c:\temp\sas*;

/* any further SAS libraries, macros, etc. or code that shall be 
executed before any SAS code processing*/

/******************************************************************/

And replace the old code in essa-sas.el with the following lines. (The 
variable <ess-sas-submit-command-options> has been missing in the 
<ess-sas-submit-region> function.):

;;;;;;;;;;;;;;;;;;;;;essa-sas.el (ll. 971-996);;;;;;;;;;;;;;;;;;;;;;;;

(defun ess-sas-submit-region ()
      "Write region to temporary file, and submit to SAS."
      (interactive)
      (ess-sas-file-path)
      (write-region (region-beginning) (region-end)
     (concat (ess-sas-temp-root) ".sas"))

      (save-excursion
        (ess-sas-goto-shell t)

      (if (and (w32-shell-dos-semantics)
     (string-equal ":" (substring ess-sas-file-path 1 2)))
     (progn
         (insert (substring ess-sas-file-path 0 2))
         (comint-send-input)
      ))

      (insert "cd \"" (convert-standard-filename
     (file-name-directory ess-sas-file-path)) "\"")
      (comint-send-input)

      (insert (concat ess-sas-submit-pre-command " " ess-sas-submit-command
            " " ess-sas-submit-command-options " " (ess-sas-temp-root) " 
" ess-sas-submit-post-command)) ;; WI-2007-10-11
      (comint-send-input)
      )
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


I hope this code will be implemeted in ESS  soon.

Best, Will

Geoffrey Smith skrev:
> Hello,
> 
> I have installed GNU Emacs and ESS on a PC running Windows XP.  Also installed on the same machine is a Windows compatible version of SAS.
> 
> I am perfectly able to write SAS code using Emacs.  The problem is that I am unable to submit my SAS program to run from Emacs.  It does not look to me that Emacs understands that I have SAS installed on my computer.
> 
> Is there a way to let Emacs know that I have a local version of SAS?  Or am I missing something?
> 
> Thank you!
> 
> Geoff Smith
> 
> ______________________________________________
> ESS-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help


-- 
Wilmar IGL (Mr.)
PhD, Psychologist

* Postal Addresses:
-Fogdevreten 13 B
SE-171 65 Stockholm/Solna
Sweden
-c/o Michael und Christa Igl
Sittling 330
D-93333 Neustadt a. d. Donau
Germany

* Phone:
- Sweden: +46 (0) 73 75 44 9 43 (mobile)
- Germany: +49 (0) 176 29 49 87 10 (mobile)
- VoIP: wilmar.igl (Skype), +49 (0) 9445 35 33 31 (landline, SkypeIn)

* E-mail: wilmar.igl[AT]gmx.de




More information about the ESS-help mailing list