Wednesday, December 23, 2015

SAS: Macro to replace missing values with zeroes for all numeric fields

Came across this nice macro. Good not only for work but for demoing the use of arrays and _numeric_.

    %macro miss2zero;
    array miss {*} _numeric_;

    do i =1 to dim(miss);
       if miss{i} = . then miss{i} = 0;
    end;
    %mend miss2zero;