sas mode for emacs
- Download (or clone)
sas.el
and put it in your emacs directory (for example the directory/home/foouser/.emacs.d/lisp
) - To use SAS as another babel language, add the following to your
.emacs
(load "/home/foouser/.emacs.d/lisp/sas.el") (require 'sas)
If you use ESS (for R) and sas you should disable the automatic loading of SAS-mode from ESS and load sas after:
(require 'ess) (setq auto-mode-alist (delete '("\\.[Ss][Aa][Ss]\\'" . SAS-mode) auto-mode-alist)) (load "/home/foouser/.emacs.d/lisp/sas.el") (require 'sas)
ESS does not update SAS-mode anymore. To have syntaxic coloration, session (as in python-mode) and keyboard shortcuts as in elpy or ESS, I have made a compilation of these sources into this sas.el. It could be used with ob-sas.el to make sas src block in org mode files. As I don’t have windows I don’t know if it works on windows.
- Start sas
In a file with sas mode enabled, start SAS with
run-sas
(M-x run-sas
) - Submit commands
sas comes with several shortcuts to submit sas commands
(defvar sas-mode-map (let ((map (make-sparse-keymap))) (define-key map "\C-c\C-r" #'sas-shell-send-region) (define-key map "\C-c\C-b" #'sas-shell-send-buffer) (define-key map "\C-c\C-j" #'sas-shell-send-line) (define-key map [(control return)] #'sas-shell-send-dwim) (define-key map "\C-c\C-v" #'sas-view-table) (define-key map "\C-c\C-q" #'sas-exit) map) "Keymap for `sas-mode'.")
- For instance a
C-RET
control-return (sas-shell-send-dwim
) in a middle of a data step or a proc step will send the whole data step or proc step to SAS. C-c C-v
(sas-view-table
) when point is on a SAS data-table print the first three lines (customizesas-view-maxnumber-of-rows
variable to change the number of displayed rows). For users who preferproc fsview
sas-fsview-table
orsas-fsview-edit-table
can be used instead.C-c C-q
will close the SAS buffers
- For instance a
- The custom variable
sas-shell-interpreter
issas
but it can be useful to point to another sas executable. - The custom
sas-sas-windows
can be set tot
if SAS windows is used - The custom
sas-realsession
can be set to nil on windows in order to create a temporary user library and submit SAS region using SAS batch mechanism. - For doom emacs
the following code in
config.el
;; to disable ESS SAS-mode (after! ess (setq auto-mode-alist (delete '("\\.[Ss][Aa][Ss]\\'" . SAS-mode) auto-mode-alist))) ;; sas-mode using sas.el (use-package sas) (after! sas (map! :map sas-mode-map :localleader "RET" #'sas-shell-send-dwim "r" #'sas-shell-send-region "j" #'sas-shell-send-line "v" #'sas-view-table "q" #'sas-exit "b" #'sas-shell-send-buffer))
and the classical loading mechanism in
package.el
(package! sas :recipe (:host github :repo "Pierre-Andre/sas-mode"))
should work.
- For windows user
sas-sas-windows
must be set to non-nil andsas-realsession
must be set to nil, for instance using the following code in.emacs
;; to disable ESS SAS-mode (require 'ess) (setq auto-mode-alist (delete '("\\.[Ss][Aa][Ss]\\'" . SAS-mode) auto-mode-alist)) ;; sas-mode using sas.el (load "/home/foouser/.emacs.d/lisp/sas.el") (require 'sas) (setq sas-sas-windows 't sas-realsession nil)