Dear Ian and Craige,
Thank you so much for your submissions. I ran some preliminary tests and Ian's solution is more than 4 times faster than Recode for this and Craige's solution is almost 10 times faster. If anyone would like to compare all 3 solutions, try the following:
//Recode solution
nr = 10000; // Number of rows
nc = 10000; // Number of columns
nm = 0.9; // Proportion of missing values
// Make a table and inject some missing values
mat = J(nr*nc, 1, RandomNormal());
mat[RandomIndex(nr*nc, nr*nc*nm)] = .;
dt = AsTable(Shape(mat, nr, nc));
dt << setName("Data with some missingness");
replaceMissingStart = HP Time();
// replace missings with zeros
nc = dt << get column names( Numeric );
For( i = 1, i <= N Items( nc ), i++,
col = Column(dt,nc[i]);
colname = col << getname();
Eval(Parse(EvalInsert("\[
dt << Recode Column(
:Name("^colname^"),
{Map Value( _rcOrig, {., 0}, Unmatched( _rcNow ) )},
Update Properties( 1 ),
Target Column( :Name("^colname^") )
);
]\")));
//Code from the Community
//Column( nc[i] )[dmdt << get rows where( Is Missing( As Column( nc[i] ) ) )] = 0;
// standardize column attributes, change all to nominal
//col << Set Modeling Type( "Nominal" )
);
replaceMissingStop = HP Time();
totalReplaceTime = replaceMissingStop-replaceMissingStart;
show(totalReplaceTime/1000000);
Russ Wolfinger had mentioned he thought matrices would solve the problem more quickly, I guess that was what you two were thinking as well!