1@ESS{[SAS]} was designed for use with @SAS{}.  It is descended from emacs
2macros developed by John Sall for editing @SAS{} programs and @code{SAS-mode} by
3Tom Cook.  Those editing features and new advanced features are part of
4@ESS{[SAS]}.  The user interface of @ESS{[SAS]} has similarities with @ESS{[S]}
5and the @SAS{} Display Manager.
6
7@comment  node-name,  next,  previous,  up
8@node ESS(SAS)--Design philosophy, ESS(SAS)--Editing files, ESS for SAS, ESS for SAS
9@section ESS[SAS]--Design philosophy
10
11@ESS{[SAS]} was designed to aid the user in writing and maintaining @SAS{}
12programs, such as @file{@var{foo}.sas}.  Both interactive and batch
13submission of @SAS{} programs is supported.
14
15@ESS{[SAS]} was written with two primary goals.
16@enumerate
17@item
18The emacs text editor provides a powerful and flexible development
19environment for programming languages.  These features are a boon to all
20programmers and, with the help of @ESS{[SAS]}, to @SAS{} users as well.
21@item
22Although a departure from @SAS{} Display Manager, @ESS{[SAS]} provides
23similar key definitions to give novice @ESS{[SAS]} users a head start.
24Also, inconvenient @SAS{} Display Manager features, like remote submission
25and syntax highlighting, are provided transparently; appealing to
26advanced @ESS{[SAS]} users.
27@end enumerate
28
29@comment  node-name,  next,  previous,  up
30@node ESS(SAS)--Editing files, ESS(SAS)--TAB key, ESS(SAS)--Design philosophy, ESS for SAS
31@section ESS[SAS]--Editing files
32
33@ESS{[SAS]} is the mode for editing @SAS{} language files.  This mode handles:
34
35@itemize @bullet
36@item
37proper indenting, generated by both @key{TAB} and @key{RET}.
38@item
39color and font choices based on syntax.
40@item
41ability to save and submit the file you are working on as a batch
42@SAS{} process with a single keypress and to continue editing while it is runs
43in the background.
44@item
45capability of killing the batch @SAS{} process through the @file{*shell*} buffer or
46allow the @SAS{} process to keep on running after you exit emacs.
47@item
48single keypress navigation of @file{.sas}, @file{.log} and @file{.lst} files
49(@file{.log} and @file{.lst} files are refreshed with each keypress).
50@item
51ability to send the contents of an entire buffer, a highlighted region,
52or a single line to an interactive @SAS{} process.
53@item
54ability to switch between processes which would be the target of the
55buffer (for the above).
56@end itemize
57
58@ESS{[SAS]} is automatically turned on when editing a file with a @file{.sas}
59suffix (or other extension, if specified via @code{auto-mode-alist}).  The function
60keys can be enabled to use the same function keys that
61the @SAS{} Display Manager does.  The interactive capabilities of @ESS{} require you
62to start an inferior @SAS{} process with @wkbd{M-x SAS}
63(@xref{iESS(SAS)--Interactive SAS processes}.)
64
65At this writing, the indenting and syntax highlighting are generally
66correct.  Known issues: for multiple line @code{*} or @code{%*} comments, only the
67first line is highlighted; for @file{.log} files, only the first line of a
68@code{NOTE:}, @code{WARNING:} or @code{ERROR:} message is highlighted; unmatched
69single/double quotes in @code{CARDS} data lines are @strong{NOT} ignored; in an
70iterative @code{DO} statement, @code{TO} and @code{BY} are not highlighted.
71
72@comment  node-name,  next,  previous,  up
73@node  ESS(SAS)--TAB key, ESS(SAS)--Batch SAS processes, ESS(SAS)--Editing files, ESS for SAS
74@section ESS[SAS]--@key{TAB} key
75
76Two options.  The @key{TAB} key is bound by default to
77@code{sas-indent-line}.  This function is used to syntactically indent
78@SAS{} code so @code{PROC} and @code{RUN} are in the left margin,
79other statements are indented @code{sas-indent-width} spaces from the
80margin, continuation lines are indented @code{sas-indent-width} spaces
81in from the beginning column of that statement.  This is the type of
82functionality that emacs provides in most programming language modes.
83This functionality is activated by placing the following line in your
84initialization file prior to a @code{require}/@code{load}:
85@example
86(setq ess-sas-edit-keys-toggle nil)
87@end example
88
89@ESS{} provides an alternate behavior for @key{TAB} that makes it
90behave as it does in @SAS{} Display Manager, i.e. move the cursor to
91the next stop.  The alternate behavior also provides a "TAB"
92backwards, @wkbd{C-@key{TAB}}, that moves the cursor to the stop to
93the left and deletes any characters between them.  This functionality
94is obtained by placing the following line in your initialization file
95prior to a @code{require}/@code{load}:
96@example
97(setq ess-sas-edit-keys-toggle t)
98@end example
99Under the alternate behavior, @key{TAB} is bound to @wkbd{M-x tab-to-tab-stop}
100and the stops are defined by @code{ess-sas-tab-stop-list}.
101
102@comment  node-name,  next,  previous,  up
103@node  ESS(SAS)--Batch SAS processes, ESS(SAS)--Function keys for batch processing, ESS(SAS)--TAB key, ESS for SAS
104@section ESS[SAS]--Batch SAS processes
105
106Submission of a @SAS{} batch job is dependent on your environment.
107@code{ess-sas-submit-method} is determined by your operating system and
108your shell.  It defaults to @code{'sh} unless you are running Windows or
109Mac Classic.  Under Windows, it will default to @code{'sh} if you are using
110a @UNIX{}-imitating shell; otherwise @code{'ms-dos} for an @acronym{MS-DOS}
111shell.  On macOS, it will default to @code{'sh}, but under Mac Classic,
112it defaults to @code{'apple-script}.  You will also set this to @code{'sh}
113if the @SAS{} batch job needs to run on a remote machine rather than your
114local machine.  This works transparently if you are editing the remote file
115via ange-ftp/EFS or tramp.  Note that
116@code{ess-sas-shell-buffer-remote-init} is a Local Variable that defaults
117to @code{"ssh"} which will be used to open the buffer on the remote host
118and it is assumed that no password is necessary, i.e. you are using
119@code{ssh-agent}/@code{ssh-add} or the equivalent (see the discussion about
120Local Variables below if you need to change the default).
121
122However, if you are editing the file locally and transferring it back and
123forth with Kermit, you need some additional steps.  First, start Kermit
124locally before remotely logging in.  Open a local copy of the file with the
125@code{ess-kermit-prefix} character prepended (the default is @code{"#"}).
126Execute the command @wkbd{M-x ess-kermit-get} which automatically brings
127the contents of the remote file into your local copy.  If you transfer
128files with Kermit manually in a @file{*shell*} buffer, then note that the
129Kermit escape sequence is @wkbd{C-q C-\ c} rather than @wkbd{C-\ c} which
130it would be in an ordinary terminal application, i.e. not in an emacs
131buffer.  Lastly, note that the remote Kermit command is specified by
132@code{ess-kermit-command}.
133
134The command used by the @code{SUBMIT} function key (@key{F3} or @key{F8})
135to submit a batch @SAS{} job, whether local or remote, is
136@code{ess-sas-submit-command} which defaults to @code{sas-program}.
137@code{sas-program} is @code{"invoke SAS using program file"} for Mac
138Classic and @code{"sas"} otherwise.  However, you may have to alter
139@code{ess-sas-submit-command} for a particular program, so it is defined as
140buffer-local.  Conveniently, it can be set at the end of the program:
141@example
142endsas;
143Local variables:
144ess-sas-submit-command: "sas8"
145End:
146@end example
147
148The command line is also made of @code{ess-sas-submit-pre-command},
149@code{ess-sas-submit-post-command} and @code{ess-sas-submit-command-options}
150(the last of which is also buffer-local).
151Here are some examples for your @initfile{}
152file (you may also use @wkbd{M-x customize-variable}):
153@example
154;'sh default
155(setq ess-sas-submit-pre-command "nohup")
156;'sh default
157(setq ess-sas-submit-post-command "-rsasuser &")
158;'sh example
159(setq-default ess-sas-submit-command "/usr/local/sas/sas")
160;'ms-dos default
161(setq ess-sas-submit-pre-command "start")
162;'ms-dos default
163(setq ess-sas-submit-post-command "-rsasuser -icon")
164;Windows example
165(setq-default ess-sas-submit-command "c:/progra~1/sas/sas.exe")
166;Windows example
167(setq-default ess-sas-submit-command "c:\\progra~1\\sas\\sas.exe")
168@end example
169
170There is a built-in delay before a batch @SAS{} job is submitted when using
171a @UNIX{}-imitating shell under Windows.  This is necessary in many cases
172since the shell might not be ready to receive a command.  This delay is
173currently set high enough so as not to be a problem.  But, there may be
174cases when it needs to be set higher, or could be set much lower to
175speed things up.  You can over-ride the default in your @initfile{} file by:
176@example
177(setq ess-sleep-for 0.2)
178@end example
179
180For example, @code{(setq ess-sas-global-unix-keys t)} keys shown,
181@code{(setq ess-sas-global-pc-keys t)} in parentheses;
182@ESS{[SAS]} function keys are presented in the next section.
183Open the file you want to work with @wkbd{C-x C-f foo.sas}.
184@file{@var{foo}.sas} will be in @ESS{[SAS]} mode.  Edit as appropriate, then save and
185submit the batch @SAS{} job.
186@example
187@key{F3} (@key{F8})
188@end example
189The job runs in the @file{*shell*} buffer while you continue to edit
190@file{@var{foo}.sas}.  If @code{ess-sas-submit-method} is @code{'sh}, then the
191message buffer will display the shell notification when the
192job is complete.  The @code{'sh} setting also allows you to
193terminate the @SAS{} batch job before it is finished.
194@example
195@key{F8} (@key{F3})
196@end example
197Terminating a @SAS{} batch in the @file{*shell*} buffer.
198@example
199kill @var{PID}
200@end example
201You may want to visit the @file{.log} (whether the job is still running
202or it is finished) and check for error messages.  The @file{.log} will be
203refreshed and you will be placed in it's buffer.  You will be
204taken to the first error message, if any.
205@example
206@key{F5} (@key{F6})
207@end example
208Goto the next error message, if any.
209@example
210@key{F5} (@key{F6})
211@end example
212Now, @samp{refresh} the @file{.lst} and go to it's buffer.
213@example
214@key{F6} (@key{F7})
215@end example
216If you wish to make changes, go to the @file{.sas} file with.
217@example
218@key{F4} (@key{F5})
219@end example
220Make your editing changes and submit again.
221@example
222@key{F3} (@key{F8})
223@end example
224
225@comment  node-name,  next,  previous,  up
226@node  ESS(SAS)--Function keys for batch processing, iESS(SAS)--Interactive SAS processes, ESS(SAS)--Batch SAS processes, ESS for SAS
227@section ESS[SAS]--Function keys for batch processing
228
229The setup of function keys for @SAS{} batch processing
230is unavoidably complex, but the usage of function keys is simple.
231There are five distinct options:
232
233Option 1 (default).  Function keys in @ESS{[SAS]} are not bound to elisp
234commands.  This is in accordance with the GNU Elisp Coding Standards
235(@acronym{GECS}) which do not allow function keys to be bound so that they are
236available to the user.
237
238Options 2-5.  Since @acronym{GECS} does not allow function keys to be bound by
239modes, these keys are often unused.  So, @ESS{[SAS]} provides users with
240the option of binding elisp commands to these keys.  Users who are
241familiar with @SAS{} will, most likely, want to duplicate the function key
242capabilities of the @SAS{} Display Manager.  There are four options (noted
243in parentheses).
244
245@enumerate a
246@item
247@SAS{} Display Manager has different function key definitions for
248@UNIX{} (2, 4) and Windows (3, 5); @ESS{[SAS]} can use either.
249@item
250The @ESS{[SAS]} function key definitions can be active in all buffers
251(global: 4, 5) or limited (local: 2, 3) only to buffers with files that
252are associated with @ESS{[SAS]} as specified in your @code{auto-mode-alist}.
253@end enumerate
254
255The distinction between local and global is subtle.  If you want the
256@ESS{[SAS]} definitions to work when you are in the @file{*shell*} buffer or when
257editing files other than the file extensions that @ESS{[SAS]} recognizes,
258you will most likely want to use the global definitions.  If you want
259your function keys to understand @SAS{} batch commands when you are editing
260@SAS{} files, and to behave normally when editing other files, then you
261will choose the local definitions.  The option can be chosen by the
262person installing @ESS{} for a site or by an individual.
263
264@enumerate a
265@item
266For a site installation or an individual, place @strong{ONLY ONE} of
267the following lines in your initialization file prior to a
268@code{require}/@code{load}.  @ESS{[SAS]} function keys are available
269in @ESS{[SAS]} if you choose either 2 or 3 and in all modes if you
270choose 4 or 5:
271@example
272;;2; (setq ess-sas-local-unix-keys t)
273;;3; (setq ess-sas-local-pc-keys t)
274;;4; (setq ess-sas-global-unix-keys t)
275;;5; (setq ess-sas-global-pc-keys t)
276@end example
277
278The names @code{-unix-} and @code{-pc-} have nothing to do with the operating system
279that you are running.  Rather, they mimic the definitions that the @SAS{}
280Display Manager uses by default on those platforms.
281
282@item
283If your site installation has configured the keys contrary to your
284liking, then you must call the appropriate function.
285@example
286 (load "ess-site") ;; local-unix-keys
287 (ess-sas-global-pc-keys)
288@end example
289@end enumerate
290
291Finally, we get to what the function keys actually do.  You may recognize
292some of the nicknames as @SAS{} Display Manager commands (they are in all
293capitals).
294
295@multitable {123456} {123456} {really-really-really-really-really-really-really-really-really-really-long}
296@item
297@UNIX{} @tab @PC @tab Nickname
298@item
299@key{F2} @tab @key{F2} @tab @samp{refresh}
300@item
301@tab @tab
302                    revert the current buffer with the file of the same
303                    name if the file is newer than the buffer
304@item
305@key{F3} @tab @key{F8} @tab @code{SUBMIT}
306@item
307@tab @tab
308                    save the current @file{.sas} file (which is either the @file{.sas}
309                    file in the current buffer or the @file{.sas} file associated
310                    with the @file{.lst} or @file{.log} file in the current buffer)
311                    and submit the file as a batch @SAS{} job
312@item
313@key{F4} @tab @key{F5} @tab @code{PROGRAM}
314@item
315@tab @tab
316                    switch buffer to @file{.sas} file
317@item
318@key{F5} @tab @key{F6} @tab @code{LOG}
319@item
320@tab @tab
321                    switch buffer to @file{.log} file, @samp{refresh} and goto next
322                    error message, if any
323@item
324@key{F6} @tab @key{F7} @tab @code{OUTPUT}
325@item
326@tab @tab
327                    switch buffer to @file{.lst} file and @samp{refresh}
328@item
329@key{F7} @tab @key{F4} @tab @samp{filetype-1}
330@item
331@tab @tab
332                    switch buffer to @samp{filetype-1} (defaults to @file{.txt}) file
333                    and @samp{refresh}
334@item
335@key{F8} @tab @key{F3} @tab @samp{shell}
336@item
337@tab @tab
338                    switch buffer to @file{*shell*}
339@item
340@key{F9} @tab @key{F9} @tab @code{VIEWTABLE}
341@item
342@tab @tab
343                    open an interactive @code{PROC FSEDIT} session on the @SAS{}
344                    dataset near point
345@item
346@key{F10} @tab @key{F10} @tab toggle-log
347@item
348@tab @tab
349                    toggle @ESS{[SAS]} for @file{.log} files; useful for certain
350                    debugging situations
351@item
352@key{F11} @tab @key{F11} @tab @samp{filetype-2}
353@item
354@tab @tab
355                    switch buffer to @samp{filetype-2} (defaults to @file{.dat}) file
356                    and @samp{refresh}
357@item
358@key{F12} @tab @key{F12} @tab viewgraph
359@item
360@tab @tab
361                    open a @code{GSASFILE} near point for viewing either in emacs
362                    or with an external viewer
363@item
364@kbd{C-@key{F1}} @tab @kbd{C-@key{F1}} @tab rtf-portrait
365@item
366@tab @tab
367                    create an @sc{MS RTF} portrait file from the current buffer
368                    with a file extension of @file{.rtf}
369@item
370@kbd{C-@key{F2}} @tab @kbd{C-@key{F2}} @tab rtf-landscape
371@item
372@tab @tab
373                    create an @sc{MS RTF} landscape file from the current buffer
374                    with a file extension of @file{.rtf}
375@item
376@kbd{C-@key{F3}} @tab @kbd{C-@key{F8}} @tab submit-region
377@item
378@tab @tab
379                    write region to @file{ess-temp.sas} and submit
380@item
381@kbd{C-@key{F5}} @tab @kbd{C-@key{F6}} @tab append-to-log
382@item
383@tab @tab
384                    append @file{ess-temp.log} to the current @file{.log} file
385@item
386@kbd{C-@key{F6}} @tab @kbd{C-@key{F7}} @tab append-to-output
387@item
388@tab @tab
389                    append @file{ess-temp.lst} to the current @file{.lst} file
390@item
391@kbd{C-@key{F9}} @tab @kbd{C-@key{F9}} @tab @code{INSIGHT}
392@item
393@tab @tab
394                    open an interactive @code{PROC INSIGHT} session on the @SAS{}
395                    dataset near point
396@item
397@kbd{C-@key{F10}} @tab @kbd{C-@key{F10}} @tab toggle-listing
398@item
399@tab @tab
400                    toggle @ESS{[SAS]} for @file{.lst} files; useful for toggling
401                    read-only
402@end multitable
403
404@code{SUBMIT}, @code{PROGRAM}, @code{LOG} and @code{OUTPUT} need no further
405explanation since they mimic the @SAS{} Display Manager commands and
406related function key definitions.  However, six other keys have been
407provided for convenience and are described below.
408
409@samp{shell} switches you to the @file{*shell*} buffer where you can
410interact with your operating system.  This is especially helpful if you
411would like to kill a @SAS{} batch job.  You can specify a different buffer
412name to associate with a @SAS{} batch job (besides @file{*shell*}) with the
413buffer-local variable @code{ess-sas-shell-buffer}.  This allows you to have
414multiple buffers running @SAS{} batch jobs on multiple local/remote
415computers that may rely on different methods specified by the buffer-local
416variable @code{ess-sas-submit-method}.
417
418@key{F2} performs the @samp{refresh} operation on the current buffer.
419@samp{refresh} compares the buffer's last modified date/time with the
420file's last modified date/time and replaces the buffer with the file if the
421file is newer.  This is the same operation that is automatically performed
422when @code{LOG}, @code{OUTPUT}, @samp{filetype-1} or @key{F11} are pressed.
423
424@samp{filetype-1} switches you to a file with the same file name as your @file{.sas}
425file, but with a different extension (@file{.txt} by default) and performs
426@samp{refresh}.  You can over-ride the default extension; for example in your
427@initfile{} file:
428@example
429(setq ess-sas-suffix-1 "csv") ; for example
430@end example
431
432@key{F9} will prompt you for the name of a permanent @SAS{} dataset near
433point to be opened for viewing by @code{PROC FSEDIT}.  You can control the
434@SAS{} batch command-line with @code{ess-sas-data-view-submit-options}.
435For controlling the @SAS{} batch commands, you have the global variables
436@code{ess-sas-data-view-libname} and
437@code{ess-sas-data-view-fsview-command} as well as the buffer-local
438variable @code{ess-sas-data-view-fsview-statement}.  If you have your
439@SAS{} @code{LIBNAME} defined in @file{~/autoexec.sas}, then the defaults
440for these variables should be sufficient.
441
442Similarly, @wkbd{C-@key{F9}} will prompt you for the name of a permanent
443@SAS{} dataset near point to be opened for viewing by @code{PROC INSIGHT}.
444You can control the @SAS{} batch command-line with
445@code{ess-sas-data-view-submit-options}.  For controlling the @SAS{} batch
446commands, you have the global variables @code{ess-sas-data-view-libname}
447and @code{ess-sas-data-view-insight-command} as well as the buffer-local
448variable @code{ess-sas-data-view-insight-statement}.
449
450@key{F10} toggles @ESS{[SAS]} mode for @file{.log} files which is off by default
451(technically, it is @code{SAS-log-mode}, but it looks the same).  The syntax
452highlighting can be helpful in certain debugging situations, but large
453@file{.log} files may take a long time to highlight.
454
455@key{F11} is the same as @samp{filetype-1} except it is @file{.dat} by default.
456
457@key{F12} will prompt you for the name of a @code{GSASFILE} near the point in @file{.log} to
458be opened for viewing either with emacs or with an external viewer.
459Depending on your version of emacs and the operating system you are
460using, emacs may support @file{.gif} and @file{.jpg} files internally.  You may need
461to change the following variables for your own situation.
462@code{ess-sas-graph-view-suffix-regexp} is a regular expression of supported
463file types defined via file name extensions.
464@code{ess-sas-graph-view-viewer-default} is the default external viewer for
465your platform.  @code{ess-sas-graph-view-viewer-alist} is an alist of
466exceptions to the default; i.e. file types and their associated
467viewers which will be used rather than the default viewer.
468@example
469(setq ess-sas-graph-view-suffix-regexp (concat "[.]\\([eE]?[pP][sS]\\|"
470"[pP][dD][fF]\\|[gG][iI][fF]\\|[jJ][pP][eE]?[gG]\\|"
471"[tT][iI][fF][fF]?\\)")) ;; default
472(setq ess-sas-graph-view-viewer-default "kodakimg") ;; Windows default
473(setq ess-sas-graph-view-viewer-default "sdtimage") ;; Solaris default
474(setq ess-sas-graph-view-viewer-alist
475  '(("[eE]?[pP][sS]" . "gv") ("[pP][dD][fF]" . "gv")) ;; default w/ gv
476@end example
477
478@wkbd{C-@key{F2}} produces US landscape by default, however, it can produce A4
479landscape (first line for "global" key mapping, second for "local"):
480@example
481(global-set-key [(control f2)] 'ess-sas-rtf-a4-landscape)
482(define-key sas-mode-local-map [(control f2)] 'ess-sas-rtf-a4-landscape)
483@end example
484
485
486@comment  node-name,  next,  previous,  up
487@node  iESS(SAS)--Interactive SAS processes, iESS(SAS)--Common problems, ESS(SAS)--Function keys for batch processing, ESS for SAS
488@section iESS[SAS]--Interactive SAS processes
489
490Inferior @ESS{} (@iESS{}) is the method for interfacing with interactive
491statistical processes (programs).  @iESS{[SAS]} is what is needed for
492interactive @SAS{} programming.  @iESS{[SAS]} works best
493with the @SAS{} command-line option settings
494@code{"-stdio -linesize 80 -noovp -nosyntaxcheck"}
495(the default of @code{inferior-SAS-args}).
496
497@display
498@code{-stdio}
499            required to make the redirection of stdio work
500@code{-linesize 80}
501            keeps output lines from folding on standard terminals
502@code{-noovp}
503            prevents error messages from printing 3 times
504@code{-nosyntaxcheck}
505            permits recovery after syntax errors
506@end display
507
508To start up @iESS{[SAS]} mode, use:
509@example
510   @wkbd{M-x SAS}
511@end example
512
513The @file{*SAS:1.log*} buffer in @code{ESStr} mode corresponds to the file
514@file{@var{foo}.log} in @SAS{} batch usage and to the @samp{SAS: LOG} window in the
515@SAS{} Display Manager.  All commands submitted to @SAS{}, informative
516messages, warnings, and errors appear here.
517
518The @file{*SAS:1.lst*} buffer in @code{ESSlst} mode corresponds to the file
519@file{@var{foo}.lst} in @SAS{} batch usage and to the @samp{SAS: OUTPUT} window in the
520@SAS{} Display Manager.  All printed output appears in this window.
521
522The @file{*SAS:1*} buffer exists solely as a communications buffer.
523The user should never use this buffer directly.
524Files are edited in the @file{@var{foo}.sas} buffer.  The @wkbd{C-c C-r} key in
525@ESS{[SAS]} is the functional equivalent of bringing a file into the
526@samp{SAS: PROGRAM EDITOR} window followed by @code{SUBMIT}.
527
528For example, open the file you want to work with.
529@example
530@wkbd{C-x C-f foo.sas}
531@end example
532@file{@var{foo}.sas} will be in @ESS{[SAS]} mode.  Edit as appropriate, and then start
533up @SAS{} with the cursor in the @file{@var{foo}.sas} buffer.
534@example
535@wkbd{M-x SAS}
536@end example
537Four buffers will appear on screen:
538@multitable {buffer-names} {long-mode-names} {much-much-much-much-longer-description}
539@item
540Buffer               @tab Mode                   @tab Description
541@item
542@file{@var{foo}.sas} @tab @code{@ESS{[SAS]}}        @tab your source file
543@item
544@file{*SAS:1*}       @tab @code{@iESS{[SAS:1]}}     @tab @iESS{} communication buffer
545@item
546@file{*SAS:1.log*}   @tab @code{Shell ESStr []}  @tab @SAS{} log information
547@item
548@file{*SAS:1.lst*}   @tab @code{Shell ESSlst []} @tab @SAS{} listing information
549@end multitable
550If you would prefer each of the four buffers to appear in its
551own individual frame, you can arrange for that.  Place the
552cursor in the buffer displaying @file{@var{foo}.sas}.  Enter the
553sequence @wkbd{C-c C-w}. The cursor will normally be in buffer
554@file{@var{foo}.sas}.  If not, put it there and @wkbd{C-x b @var{foo}.sas}.
555
556Send regions, lines, or the entire file contents to @SAS{}
557(regions are most useful:  a highlighted region will normally
558begin with the keywords @code{DATA} or @code{PROC} and end with
559@code{RUN;}), @wkbd{C-c C-r}.
560
561Information appears in the log buffer, analysis results in the
562listing buffer.  In case of errors, make the corrections in the
563@file{@var{foo}.sas} buffer and resubmit with another @wkbd{C-c C-r}.
564
565At the end of the session you may save the log and listing
566buffers with the usual @wkbd{C-x C-s} commands.  You will be prompted
567for a file name.  Typically, the names @file{@var{foo}.log} and @file{@var{foo}.lst}
568will be used.  You will almost certainly want to edit the saved
569files before including them in a report.  The files are
570read-only by default.  You can make them writable by the emacs
571command @wkbd{C-x C-q}.
572
573At the end of the session, the input file @file{@var{foo}.sas} will
574typically have been revised.  You can save it.  It can be used
575later as the beginning of another @iESS{[SAS]} session.  It can
576also be used as a batch input file to @SAS{}.
577
578The @file{*SAS:1*} buffer is strictly for @ESS{} use.  The user should
579never need to read it or write to it.  Refer to the @file{.lst} and
580@file{.log} buffers for monitoring output!
581
582Troubleshooting: @xref{iESS(SAS)--Common problems}.
583
584@comment  node-name,  next,  previous,  up
585@node   iESS(SAS)--Common problems, ESS(SAS)--Graphics, iESS(SAS)--Interactive SAS processes, ESS for SAS
586@section iESS[SAS]--Common problems
587
588@enumerate
589@item
590@iESS{[SAS]} does not work on Windows.  In order to run @SAS{} inside
591an emacs buffer, it is necessary to start @SAS{} with the @code{-stdio} option.
592@SAS{} does not support the @code{-stdio} option on Windows.
593@item
594If @wkbd{M-x SAS} gives errors upon startup, check the following:
595@itemize @bullet
596@item
597you are running Windows:  see 1.
598@item
599@file{ess-sas-sh-command} (from the @ESS{} @file{etc} directory) needs to be
600executable; too check, type @wkbd{M-x dired}; if not, fix it as follows,
601type @kbd{M-:}, then at the minibuffer prompt @wsamp{Eval:},
602type @code{(set-file-modes "ess-sas-sh-command" 493)}.
603@c (solution: @code{chmod ugo+rx ess-sas-sh-command}).
604@item
605@code{sas} isn't in your executable path; to verify, type
606@kbd{M-:} and at the minibuffer prompt @samp{Eval:}, type
607@code{(executable-find "sas")}
608@end itemize
609@item
610@wkbd{M-x SAS} starts @w{@SAS{} Display} Manager.  Probably, the command @code{sas}
611on your system calls a shell script.  In that case you will need to locate
612the real  @code{sas} executable and link to it.
613You can execute the @UNIX{} command:
614@example
615find / -name sas -print
616@end example
617Now place a soft link to the real @code{sas} executable in your @code{~/bin}
618directory, with for example
619@example
620cd ~/bin
621ln -s /usr/local/sas9/sas sas
622@end example
623@end enumerate
624Check your @code{PATH} environment variable to confirm that
625@code{~/bin} appears before the directory in which the @code{sas}
626shell script appears.
627
628@comment Specify the path to the real
629@comment @code{sas} executable in @file{ess-sas-sh-command}, i.e.:
630@comment @example
631@comment /usr/local/sas9/sas $@@ </dev/tty 1>$stdout 2>$stderr
632@comment @end example
633@comment    To find the @code{sas} executable, you can execute the @UNIX{} command:
634@comment @example
635@comment find / -name sas -print
636@comment @end example
637@comment @end enumerate
638
639@comment  node-name,  next,  previous,  up
640@node   ESS(SAS)--Graphics, ESS(SAS)--Windows, iESS(SAS)--Common problems, ESS for SAS
641@section ESS[SAS]--Graphics
642
643Output from a @SAS{/GRAPH} @code{PROC} can be displayed in a @SAS{/GRAPH}
644window for @SAS{} batch on Windows or for both @SAS{} batch and interactive
645with XWindows on @UNIX{}.  If you need to create graphics files and view
646them with @key{F12}, then include the following (either in
647@file{@var{foo}.sas} or in @file{~/autoexec.sas}):
648@example
649filename gsasfile 'graphics.ps';
650goptions device=ps gsfname=gsasfile gsfmode=append;
651@end example
652@code{PROC PLOT} graphs can be viewed in the listing buffer.  You may
653wish to control the vertical spacing to allow the entire plot
654to be visible on screen, for example:
655@example
656proc plot;
657    plot a*b / vpos=25;
658run;
659@end example
660
661@comment  node-name,  next,  previous,  up
662@node   ESS(SAS)--Windows,  , ESS(SAS)--Graphics, ESS for SAS
663@section ESS[SAS]--Windows
664
665@itemize @bullet
666@item
667@iESS{[SAS]} does not work on Windows.  @xref{iESS(SAS)--Common problems}.
668
669@item
670@ESS{[SAS]} mode for editing @SAS{} language files works very well.
671@xref{ESS(SAS)--Editing files}.
672
673@item
674There are two execution options for @SAS{} on Windows.
675You can use batch.  @xref{ESS(SAS)--Batch SAS processes}.
676
677Or you can mark regions with the mouse and submit the code with
678`submit-region' or paste them into @SAS{} Display Manager.
679
680@end itemize
681
682@comment Local Variables:
683@comment TeX-master: "ess.texi"
684@comment End:
685