~ubuntu-branches/ubuntu/edgy/ess/edgy

« back to all changes in this revision

Viewing changes to doc/help-sas.texi

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-11-11 00:51:43 UTC
  • mfrom: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20041111005143-wv1cih1h04xyrxrb
Tags: 5.2.3-3
* repair broken replace-regexp-in-string -> ess-replace-regexp-in-string
  patch
* expand autoload functionality in emacsen-startup

Show diffs side-by-side

added added

removed removed

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