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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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