Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
    
CoffeeScript is very ruby-esque. I would imagine that the choice had a lot to do with personal preference. There is also this. –  Robert Harvey Jun 11 '13 at 22:40
    
Instead how about implementing a parser interpreter for SAS that compiles to SOMETHING else or runs WITHOUT sas installed (and you can add your syntactic sugar on top of that)? –  Jay Stevens Jun 21 '13 at 2:17
    
Interesting. I am also trying to write a SAS data step compiler that compiles to R. However, it's difficult to replicate the "infrastructure" already in place in SAS. There's a reason why a lot of programming languages nowadays compiles into Javascript (or can be used with JVM). Most browsers can run Javascript. But not many (if any) can run CoffeeScript natively, as nice as CoffeeScript is, getting all those browsers onboard will be a long and difficult process. Hence it's better to just compile to Javascript first and now your language has access to all of the existing Javascript resources. –  xiaodai Jun 21 '13 at 9:33
    
I would think a language like Ruby or Python might be useful. I was going to initially say C or C++, as what you are going to need to do is to write a compiler, which C is perfect for. I'm not sure you even need a compiler for a project like this. What you just need is a parser that can change the code from your 'Cool-SAS' into normal SAS. You won't be able to run it without SAS though, so maybe building a parser that transforms your input into SAS output, which you copy/paste into SAS might work. –  Joe Nov 19 '13 at 20:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.