Friday, August 9, 2013

More SQL taste in SAS 9.4

Compared with SAS 9.3, the latest SAS 9.4 introduced a few new procedures for the BASE and STAT components: 7 new procedures for BASE 9.4 and 4 for STAT 12.3. 6 high-performance procedures (thanks to Dr. Wicklin's correction).
New in BASE 9.4New in STAT 12.1New in STAT 12.3
DELETEADAPTIVEREGHPGENSELECT
DS2QUANTLIFEHPLOGISTIC
JSONQUANTSELECTHPLMIXED
PRESENVSTDRATEHPNLMOD
STREAMHPREG
FEDSQLHPSPLIT
AUTHLIB
DS2 is a new SAS proprietary programming language that is appropriate for advanced data manipulation.It is exciting to see the emergence of DS2 and FEDSQL. According to SAS 9.4 DS2 Language Reference,
DS2 is a SAS programming language that is appropriate for advanced data manipulation
Contrary to the thought I had last year, DS2 or PROC DS2 is not a complied language. It seems more like a wrapper of PROC FEDSQL, which combines the capacity of SQL and the original DATA Step together. Therefore, DS2 includes many SQL's features such as subquery.
data class;
   set sashelp.class;
run;

proc datasets nolist;
   delete _:;
quit;

proc ds2 stimer;
   data _test1;
      dcl varchar(6) gender;
      method run();
         set {select name, sex from class where age > 12};
         if sex = 'M' then gender = 'Male';
         else gender = 'Female';
      end;
   enddata;
   run;
quit;
The functionality is equivalent to the SQL syntax in SAS below.
proc sql stimer;
   create table _test2 as
   select *, case when sex = 'M' then 'Male'
         else 'Female'
      end as gender
   from (select name, sex from class where age > 12)
;quit;
Additionally, DS2 supports the concept of transaction in SQL. The run statement in DS2 is equal to the COMMIT statement in SQL, while run cancel statement is comparable to SQL'sROLLBACK statement.
In conclusion, with DS2, SAS is leaning toward RDBMS in how to understand and deal with data.

Good math, bad engineering

As a formal statistician and a current engineer, I feel that a successful engineering project may require both the mathematician’s abilit...