Hi, I have a variable numrec, I wish to turn the missing value into zero. How do i do it?
I have used a long way like this:
data want;
set base;
if numrec=. then numrec1=0;
run;
data want;
set want;
numrec2=sum(numrec,numrec1);
run;
Try:
new_num = sum(numrec,0) ;
Do you want all the variables which are missing to be zero ?
data class;
set sashelp.class;
if ranuni(-1) lt .4 then call missing(of _numeric_);
run;
proc stdize data=class out=new_class reponly missing=0;run;
Ksharp
hi ... if it's only one variable ...
data x;
input numrec @@;
datalines;
. 1 2 3 0 . 7 8
;
data x;
set x;
numrec+0;
run;
Hi,
Try this..
data have;
input no no1 no2;
cards;
2 . 4
. 3 6
2 8 .
. . .
;
run;
data want;
set have;
array xx[3] no no1 no2;
do i=1 to dim(xx);
if xx=. then xx=0;
end;
run;
Thanks,
Shiva
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.