As a side project I wrote a simple macro in SAS to add syntatic sugar to SAS code. I hate how verbose SAS is sometimes!
So my macro looks like this
%macro md(code);
/* expects a superquoted string */
* append a b;
%if %lowcase(%scan(&code.,1)) = append %then %do;
proc append base = %scan(&code.,2) data=%scan(&code.,3); run;
%end;
%mend;
Instead of writing
proc append base=a data=b; run;
to append two datasets, I can simply write
%md( append a b);
This got me thinking. Since I work with SAS all day and I enjoy programming. Why not (for fun) design a new data processing language that compiles to SAS?! As many of you can guess this idea was inspired by CoffeeScript which compiles to Javascript.
I learnt that CoffeeScript was initially written in Ruby? But why? How did the author choose Ruby? What are the things to consider in choosing a language? And what resources are available that might be useful in pursuing this?
5
Your simplified language will use no/few options, so will be very limited.
For example, no “force” option in your append macro.
If you want a richer language, your macros will become … the sas language.
It is usual and common to write macros that do many things, not just replace 7 words
proc append base=a data=b; run;
with 3 words.
%md( append a b);
Where are the savings in that? You save 3 words and lose all the options.
A better use for macros is to do more complex things, like finding the top-10 values and plotting them, or sorting and de-duping a macro list.