Using the SAS Enhanced Editor

Download Report

Transcript Using the SAS Enhanced Editor

Using the SAS Enhanced Editor
Rob Krajcik
Bristol-Myers Squibb
11Aug2004
Hartford Area SAS Users Group
Topics
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Why use the Enhanced Editor?
Editor Options Window
Two Sets of Keys
Opening Files
Multiple Views
Editor Line Commands
Explorer Window
Context-Sensitive Help
Viewtable Window
Selecting Text
Drag and Drop Editing
DM Key Customization
Toolbar Customization
Other Customizations
Keyboard Shortcuts
Abbreviations
Keyboard Macros
New Environment Variables
Why Use the Enhanced Editor?
• Colorizes program elements, quoted strings,and comments;
easy to spot typos, missing quotes, semi-colons,
run-on comments, and do-end blocks
• View the high-level flow of your program
• Extensible – add keys and toolbar icons
• Allows multiple instances (edit windows)
• Allows multiple views of the same file
• Can bookmark lines for easy access
• Drag and drop editing
• View->My Favorite Folders (Explorer)
• Context-sensitive help
• Customize keyboard shortcuts
• Abbreviations & Macros
Editor Options Window
Tools -->Options -->Enhanced Editor
Two Sets of Keys
Tools --> Options --> Enhanced Editor Keys
Opening Files
• Click on the FILEOPEN toolbar button
• Type FILEOPEN (or DLGOPEN) on the command line
•
•
•
•
Click on File->Open Program on the menu
Click on File->Open Object on menu (SCL)
Type INC “<.\>name.sas” on the command line
Type WEDIT “<.\>name<.sas>” on the command line
• Type FILEOPEN “<.\>name<.sas>” on the command line
• Type WHOSTEDIT ENTRY=“libname.catname.name.source” (SCL)
• Drag the .sas program from the explorer window and hold it
on the SAS icon – an enhanced editor window will open
Multiple Views
Window -->New Window
and arrange them
anyway you like.
Changes to one will be
reflected in the other(s)
Editor Line Commands
SAS Text Editor Line Commands
These commands can be executed by typing in the
numbered part (sequential numbers) of the display
and pressing ENTER. Follow line commands that have
a numeric argument with a space before issuing them.
C,CC
CL, CU, CCL, CCU
COLS
D,DD
I,IA,IB
JC, JL, JR,
JJC, JJL, JJR
M,MM
MCL,MCU
MASK
------
Copy
Case L (U)
Show columns
Delete
Insert
-----
R,RR
TC,TF,TS
---
TABS
>, >>, ), ))
<, <<, (, ((
----
Justify
Move
Case L (U) Marked
Define initial
contents of a line
Repeat
Text Connect
(Flow) (Split)
Show Tabs
Shift right
Shift left
SAS Enhanced Editor Line Commands
These commands can be executed by selecting
a line number (CTRL-G, for example) and typing the
command in the command bar.
:In, IAn – Insert n lines after the current line.
:IBn – Insert n lines before the current line.
:Dn – Delete n lines starting at the current line.
:Rn m – Repeat the block of m lines,
starting with the current line, n times.
A space is required between n and m.
Explorer Window
In SAS 9.1, There is a link to "My Computer" as
well as Libraries and File Shortcuts!
Context-Sensitive Help
Place cursor on, or select, a
a dark blue section of code
and hit F1
Viewtable Window
Selecting Text
• Click and Hold LMB
• Press Shift and a
directional key
• Can Submit / Rsubmit
selected text
• Can Also upcase /
lowcase selected text
CTRL+SHIFT+L
CTRL+SHIFT+U
Drag and Drop Editing
Hold the CTRL button
while dragging selection.
DM Key Customization
data _null_;
if resolve('&sysprocessname') = 'DMS Process'
then do;
/* Program Function Key modifications */
call execute("dm wedit 'Keydef ''CTL Y'' title' wedit;");
call execute("dm wedit 'Keydef ''CTL T'' paste' wedit;");
call execute("dm wedit 'Keydef ''CTL H'' ~
' wedit;");
call execute("dm wedit 'Keydef ''CTL F11'' cle log ' wedit;");
call execute("dm wedit 'Keydef ''CTL F12'' cle out ' wedit;");
call execute("dm wedit 'Keydef ''SHF F2'' vt _last_;edit ' wedit;");
call execute("dm wedit 'Keydef ''SHF F9'' gsub buf=default ' wedit;");
call execute("dm wedit 'Keydef ''SHF F11'' dlgopen ' wedit;");
call execute("dm wedit 'Keydef ''SHF F12'' dlgsave ' wedit;");
/* Save dmkeys and toolbox customizations to local catalog */
call execute('libname here ".";');
call execute('proc catalog cat=here.profile;');
call execute('
copy out=sasuser.profile;');
call execute('
select dmkeys /et=keys; ');
call execute('
select sasedit_main / et=toolbox;');
call execute('quit;');
call execute('libname here;');
end;
stop;
run;
Toolbar Customization
Tools --> Customize
Note: Gsubmit macro in quotes
Other Customizations
• Get SCL Source files to open in Enhanced Editor
instead of NOTEPAD (From a SAS-L post).
• To use the enhanced editor for SCL entries, bring up
the SAS Registry (issue the REGEDIT command or go to
Solutions -> Accessories -> Registry Editor). Expand
Products -> AF -> Design Time -> Source Window. Right
click on EnhancedEditor -> Modify and change value to
Yes.
• Tools -> Options -> Explorer. Select "catalog
entries" from the combobox, scroll down to SOURCE and
double click.
• Change
NOTEPAD %8B.%32B.%32B.%8B
to:
WHOSTEDIT ENTRY="%8B.%32B.%32B.%8B"
Some Keyboard Shortcuts
Alt + [ , Alt + ]
Alt + Down
Alt + F8
Alt + Shift + R
Alt + Up
Ctrl + /
Ctrl + A
Ctrl + Backspace
Ctrl + C
Ctrl + Delete
Ctrl + Down
Ctrl + F
Ctrl + F2
Ctrl + G
Ctrl + H
Ctrl + Page Down
Ctrl + Page Up
Ctrl + Shift + /
Ctrl + Shift + A
Ctrl + Shift + L
Ctrl + Shift + M
Ctrl + Shift + U
Ctrl + Shift + W
Ctrl + V
Ctrl + X
Ctrl + Y
Ctrl + Z
Move cursor to matching DO/END keyword
Move cursor to the last visible line
Play a command/macro
Start/Complete macro
Move cursor to the first visible line
Comment the selection with line comments
Select all
Delete to previous word start
Copy selection
Delete to next word start
Scroll screen up
Find (interactive)
Toggle marker on the current line (bookmark)
Go to line (interactive)
Replace (interactive)
Move cursor to the bottom of the file
Move cursor to the top of the file
Undo the Comment
Add a new abbreviation
Convert the selected text to lowercase
Add or change macros
Convert the selected text to uppercase
Clean up whitespace
Paste from clipboard
Cut selection
Redo
Undo
Keyboard Shortcuts – CTRL+G
CTRL+G
Keyboard Shortcuts – CTRL+F2
Keyboard Shortcuts – CTRL+F (dlgfind)
Keyboard Shortcuts – CTRL+H (dlgreplace)
Abbreviations - Creating
in Editor Window, Hit CTRL+A & CTRL+C | CTRL+X
Tools->Add Abbreviation
-or- CTRL+SHIFT+A
Name it, and then hit
CTRL+V in the Text Box
Abbreviations - Using
Type in the word “signon”...
And then hit the TAB | ENTER key
Keyboard Macros - Recording
Tools->Keyboard Macros->Record New Macro
-or- ALT+Shift+R. Start Typing. When Done,
Tools->Keyboard Macros->Stop Recording
-or- ALT+Shift+R.
Keyboard Macros - Saving
Fill out Save Keyboard
Macro and Click Assign
Keys.
Next, enter a shortcut
Key (like CTRL+F5) and
Click Assign, and OK.
Keyboard Macros - Maintenance
Tools->Keyboard Macros->Macros
-or- CTRL+Shift+M
Click Export,
and Save as a Keyboard
Macro File.
From Abbreviation To Keyboard Macro
Tools->Keyboard
Macros->Macros or- CTRL+Shift+M
Now click on
Assign Keys and
(optionally) Edit
to add description.
Your Abbreviation
is now a Macro.
New Environment Variables
155
dm wedit 'file shoe_report.sas' wedit;
156
proc report nowd data=sashelp.shoes(obs=10);
157
run;
NOTE: There were 10 observations read from the data set SASHELP.SHOES.
NOTE: PROCEDURE REPORT used (Total process time):
158
real time
0.00 seconds
cpu time
0.01 seconds
%put Sysprocessname is &sysprocessname;
Sysprocessname is DMS Process
159
%put Submitted File Path is %sysget(SAS_EXECFILEPATH);
Submitted File Path is C:\Documents and Settings\krajcikr\shoe_report.sas
160
%put Submitted File Name is %sysget(SAS_EXECFILENAME);
Submitted File Name is shoe_report.sas
Environment Variables
SAS_EXECFILEPATH and
SAS_EXECFILENAME are
New with Version 9.1
Questions?
References:
• Paul Grant, “Creating Code Templates in the SAS Enhanced Editor
Using Abbreviations and User Defined Keywords”, Sep 2002 BASUG,
http://www.basug.org/downloads/0303_saseditor.pdf
• Arthur L Carpenter, “Creating Display Manager Abbreviations and
Keyboard Macros for the Enhanced Editor” SUGI 28 Proceedings,
http://www2.sas.com/proceedings/sugi28/108-28.pdf
• SAS Institute, Inc. “SAS 9.1 Companion for Windows”,
http://support.sas.com/documentation/onlinedoc/91pdf/index_912.html