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

naturally treated as 0's?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@edasdfasdfasdfa wrote:

naturally treated as 0's?

 

 


No they are treated naturally as missing.  So depending on what you are doing the result is what your would normally expect.

So simple operators, like +-*/, will generate a missing values as a result of operating on one or more missing values.

But more complex operations like MIN(), MAX(), SUM(), MEAN() will work appropriately.  So if your data values are 

1 . 2 3 4 

The SUM() will be 10, but the MEAN() will be 10/4 = 2.5 and NOT 10/5=2 since the missing values does not contribute.

View solution in original post

9 REPLIES 9
PeterClemmensen
Tourmaline | Level 20

No. Missing values are treated as less than any number you think of in SAS. Including zero.

 

 

edasdfasdfasdfa
Quartz | Level 8
haha. thanks for the laugh!
novinosrin
Tourmaline | Level 20

Hi @edasdfasdfasdfa  For all I know,0 isn't missing. Missing values are valid values that does not have a value in other words a blank value. 

Using operator(arithmetic) propagates missing values while functions ignore missing values. 

 

 

edasdfasdfasdfa
Quartz | Level 8
Thanks, Novinorsin.
No doubt that missing values might be valuable and are not the same as 0's..but how we would go about setting numeric missing to zero? I was wondering if this was the default behavior?
novinosrin
Tourmaline | Level 20

"I was wondering if this was the default behavior?"-- No default is just plain missing as-is

 

"but how we would go about setting numeric missing to zero?"  

 

Do you mean this?  options missing=0;

 


options missing=0;

data w;
k=.;
run;

 


@edasdfasdfasdfa wrote:
Thanks, Novinorsin.
No doubt that missing values might be valuable and are not the same as 0's..but how we would go about setting numeric missing to zero? I was wondering if this was the default behavior?

 

seeff
Obsidian | Level 7

You've gotten many responses about the behavior of missing values, but it sounds like you're asking how to set numeric missing to zero. Perhaps this previous post is what you're looking for:

 

https://communities.sas.com/t5/SAS-Procedures/How-to-set-all-missing-values-to-zero-for-all-variable...

edasdfasdfasdfa
Quartz | Level 8

Using operator(arithmetic) propagates missing values while functions ignore missing values. 

 

What if you use a function with an operator?

Ie sum(of var1-var9) ?

novinosrin
Tourmaline | Level 20

should your operands(variable values) are all missing, of course you would get the result as missing too, otherwise, the propagation of missing values doesn't occur when you use functions. For example,

 

options missing=0;

data w;
k=sum(.,.,.,.,20);
k1=sum(.,.,.,.,.,.);
k2=.+.+.+20;
run;
options missing=.;

data w;
k=sum(.,.,.,.,20);
k1=sum(.,.,.,.,.,.);
k2=.+.+.+20;
run;
Tom
Super User Tom
Super User

@edasdfasdfasdfa wrote:

naturally treated as 0's?

 

 


No they are treated naturally as missing.  So depending on what you are doing the result is what your would normally expect.

So simple operators, like +-*/, will generate a missing values as a result of operating on one or more missing values.

But more complex operations like MIN(), MAX(), SUM(), MEAN() will work appropriately.  So if your data values are 

1 . 2 3 4 

The SUM() will be 10, but the MEAN() will be 10/4 = 2.5 and NOT 10/5=2 since the missing values does not contribute.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 9 replies
  • 883 views
  • 4 likes
  • 5 in conversation