Download orderidx.sasSubmit a comment

%macro orderIDX (data, indexvar);

  %* data     - name of data set on which to create an index;
  %* indexvar - list of data set variables to index;

  %* Richard A. DeVenezia 12/23/98;
  %* Create an index named 'order' on a dataset using variables in indexvar;

  %local LIB MEM;

  %if (%scan (&DATA,2,.) =) %then %do;
    %let LIB=WORK;
    %let MEM=&DATA;
  %else %do;
    %let LIB=%scan(&DATA,1,.);
    %let MEM=%scan(&DATA,2,.);

  proc datasets nolist lib=&LIB;
    modify &MEM;
    %if (%scan (&indexvar,2) eq ) %then
      index create &indexvar;
      index create order=(&indexvar);

%mend orderidx;