Help using Base SAS procedures

Turning missing value to zero value

Accepted Solution Solved
Reply
Contributor mei
Contributor
Posts: 62
Accepted Solution

Turning missing value to zero value

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;


Accepted Solutions
Solution
‎06-13-2012 11:11 PM
Frequent Contributor
Posts: 87

Re: Turning missing value to zero value

Try:

new_num = sum(numrec,0) ;

View solution in original post


All Replies
Solution
‎06-13-2012 11:11 PM
Frequent Contributor
Posts: 87

Re: Turning missing value to zero value

Try:

new_num = sum(numrec,0) ;

Super User
Posts: 9,681

Re: Turning missing value to zero value

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

Valued Guide
Posts: 765

Re: Turning missing value to zero value

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;

Super Contributor
Posts: 349

Re: Turning missing value to zero value

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 420 views
  • 0 likes
  • 5 in conversation