Character substitutions in the SAS editor

This post was kindly contributed by Ken's SAS tricks - go there to comment and to read the full post.

Rick Wicklin dropped a gem today!  The SAS enhanced editor includes a text replacement feature– who knew?  The use of it is laid out in this SAS paper.

Briefly, just click on Tools > Add Abbreviation, then type in the shortcut and the text to replace it with.  When you type that sequence, the editor displays it in a box.  You have the option to get all the text included in your document (by pressing enter) or of ignoring it (by typing any other key).  Edit the substitution under Tools > Keyboard Macros > Macros.

I immediately defined the following abbreviations, which I expect to save me many keystrokes.  I’m a terrible typist.  I also have been known to forget a by statement with my merges, and even to forget key statements or options in procedures I used often.

 

_pri proc print data = d (obs = n); var v; run;
_mer
proc sort data = d1; by b; run;
proc sort data = d2; by b; run;
data n;
merge d1 d2;
by b;
run;
rand(‘BINOMIAL’, <p>, <n>)  = _rbi
mixed
proc mixed data = d noclprint;
class ;
model ;
random /subject=;
run;

Abbreviation: _pri
Text:
proc print data = d (obs = n); var v; run;

Abbreviation: _mer
Text:
proc sort data = d1; by b; run;
proc sort data = d2; by b; run;
data n;merge d1 d2;by b;
run;

Abbreviation: _rbi  
Text:
rand(‘BINOMIAL’, <p>, <n>) ;
(I always forget the order of p and n in this one!)

Abbreviation: mixed
Text:
mixed data = d noclprint;
class ;
model ;
random /subject=;
run;
(Here, if I type “proc mixed” the shell for the proc appears.  Sweet!)

Abbreviation: glimmix
Text:
glimmix data = noclprint method=laplace;
class ;
model   / dist =;
random / subject=;
run;

 

 

This post was kindly contributed by Ken's SAS tricks - go there to comment and to read the full post.