BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mei
Calcite | Level 5 mei
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
SteveNZ
Obsidian | Level 7

Try:

new_num = sum(numrec,0) ;

View solution in original post

4 REPLIES 4
SteveNZ
Obsidian | Level 7

Try:

new_num = sum(numrec,0) ;

Ksharp
Super User

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

MikeZdeb
Rhodochrosite | Level 12

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;

shivas
Pyrite | Level 9

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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