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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.