Nice comment from Peter (above). Personally, I like this kind of 'tokenized' syntax for a macro call but there are some drawbacks :

1) code editors with syntax highlighting sometimes react badly with an implicit %put &macroname inside a macro code , because unexpectedly the line doesn't end with a semi-colon

&macroname /* no ';' here so the parser might be baffled */

2) also since this syntax is not used very often - at least from my experience, developers are not so accustomed to it and the macro code could be difficult to maintain/understand at first sight.

I have run the code provided by Chris (thanks for sharing !) to see for myself how it worked with concatenated libraries since I didn't know several different engines could be concatenated.

I have come across a slight problem with a "i" format unknown to %sysfunc or even to myself !
And of course, as DICTIONARY views store values only in uppercase letters, I had to modify the first request like this :

%let dsid=%sysfunc(open(sashelp.vlibnam(where=(libname="%UPCASE(&libref.)"))));

this way, the parameter is not case-sensitive and you can use %getEngine(libRef) as well as %getEngine(LIBREF) by default.

I have assigned three 1st level libraries :

libname testv6 V6 '';

libname testv8 V8 '';

libname testv9 'V9 ';

/* 1st concatenation order */

libname testconc (testv6 testv8 testv9);
%getEngine(testconc)

/* result : */
TestConc ENGINE is V6

etc.

you can do the same by changing the order of the 1st level librefs in the assignment of the concatenated libraries : (I infer that ) the rule is that the 'compound' engine is the engine of the 1st libref which is the Output by order of precedence.
http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p0pynzuflex5orn1pkeycdeivuex.htm

The VLIBNAM/LIBRARIES retains the engine ot its first member in the case of a concatenated library and this means that it could retrieve data erroneously because it would apply this engine to the other members, wouldn't it ? I have missed something, to be sure.

Ronan