As Tom just pointed out, you want to do this using an array. Rather than
specify the individual variables like varA1-varA50 , you could use
Array myarray _numeric_ ;
Which refers to all numeric variables in the data set.
Now, do you really need to change the values to zero or is this simply for
the purpose of seeing zeros in printed output. If it is purely for
appearance sake, you could specify
Options missing = 0;
And zeros will print in place of periods.
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Randy
Sent: Sunday, April 15, 2012 10:03 AM
Subject: How to change many missing variables to 0 in a single data step
I have many variables and some of the values are missing. I want to change
the missing values to 0 in a single data step.
The code I have written is:
Data want ; set have;
if VarA1 - VarA50 = . then VarA1 - VarA50 = 0 ; run;
I am getting an error term. What is the mistake that I am making?