Slick approach. However, there is the catch: monotonic() is undocumented ,unsupported by SAS. Which means, there is a possibility (although remote) that you wake up one day and your code stop working and you can't complain about it. If you are sure your 'sum' will always end up the way it is, here is another approach, which is officially supported by SAS without involving macro variables or SQL, and I also suspect it will be more efficient as well. data h1 h2; set sashelp.class; output h1; age=age*10; weight=weight*5; height=height*5; output h2; run; ods listing close; ods output comparesummary=sum; proc compare base=h1 compare=h2 ; run; ods output close; ods listing; data want (drop=i type batch _s); array vr(*) $ variable type len ndif maxdif; do _n_=1 by 1 until (last); set sum end=last nobs=nobs; if upcase(compress(batch))= 'VARIABLESWITHUNEQUALVALUES' THEN _s=_n_; end; do _n_=_s+4 to nobs-1; set sum point=_n_; do i=1 to dim(vr); vr(i)=scan(strip(batch),i); end; output; end; stop; run; Good Luck! Haikuo Edit: Yeti, I hesitated on offering critique on your code, but considering it may help you in the future, here is my 2 cents, hope you don't mind: 1. You don't need to create table 'sum1' in order to assign values to marcro variables. Creating unnecessary table not only slow you down , but also take more storage. Simply comment out 'create table' statement, the rest of your code will still work. 2. Why drop all of the work library tables? they will be dropped automatically once the session ends. Unless you really are strained by runtime storage shortage, and then you will probably want considering using views instead of tables.
... View more