—•Today is •—

Put existing variables into one array and create another array to hold values "true" and "false". Since an initial value of "true" is given for all variables in the ALLMISS array, they are retained until a new value is assigned according to the IF statement. After all observations have been read and the values of ALLMISS1-ALLMISS8 have been assigned accordingly, any left as 'true' indicate a variable that needs to be dropped. These variable names are put into a macro variable, MLIST, and then used on a DROP statement in the next step.


options mlogic mprint symbolgen;

data _null_;
  array test(8) x1-x4 y1-y4;
  array allmiss (8) $ (8*'true');
  length list $ 50;
  set missing end=end;
  do i=1 to dim(test);
    if test(i) ne . then allmiss(i)='false';
  end;
  if end=1 then 
  do i= 1 to dim(test);
    if allmiss(i) ='true' then list=trim(list)||' '||trim(vname(test(i)));
  end;
  call symput('mlist',list);
run;

data notmiss;
  set missing;
  drop &mlist;
run;
				

Print Document

Copyright © 2007 www.nycinformatics®.com All Rights Reserved
Last edited on: June 3, 2007
SAS product or service names are registered trademarks of SAS Institute, Inc. in the USA and other countries.
® indicates USA registration.