Wednesday, October 18, 2006

Using The SUM Function to Prevent Missing Values

You can use the SUM function to prevent missing values if one argument has a missing value.

The syntax for using the SUM function to create a new variable is:
newvar=sum(var1, var2);
The SUM function ignores missing values, so if var1 and var2 are both missing values then the value of newvar will also be missing.

You can prevent that by coding in a constant zero:
newvar=sum(var1, var2, 0);

In the following example:
1. A data set is created by reading in three variables: var1, var2 and var3.
Note that the third observation has missing values for var1 and var2.

2. The SUM function is used to create newvar1, which is the sum of var1 and var2.

3. The SUM function is also used to create newvar2 by summing var1 and var2, but it also codes in a constant zero.

data step1;
input @1 var1 1-2
@4 var2 4-5
@7 var3 7-8
;
newvar1=sum(var1, var2);
newvar2=sum(var1, var2,0);
datalines;
10 20 15
10 10 25
35
20 20 45
;
run;

proc print data=step1;
var var1 var2 newvar1 newvar2;
run;
quit;


For the third observation, there is a missing value for newvar1. But by including a zero in the SUM statement for newvar2, the value of the third observation is zero instead of missing.

8 Comments:

At 11:04 PM, Blogger sandeep saxena said...

Nice blog,Thanks for giving wonderful information.keep sharing more like this.
clinical sas training in chennai
clinical sas course
clinical sas Training in Anna Nagar
SAS Training in Chennai
SAS Training Institute in Chennai
Placement Training in Chennai
soft skills training in chennai
core java training in chennai

 
At 7:14 AM, Blogger aaron said...

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as an updated one, keep blogging.

Cloud Migration Services
AWS Cloud Migration Services
Azure Cloud Migration Services
VMware Cloud Migration Services
Cloud Migration tool
Database Migration Services
Cloud Migration Services


 
At 4:31 AM, Blogger high technologies solutions said...

great post.
sas training in delhi
sas training in noida

 
At 4:15 AM, Blogger Arjundevan said...

awesome article,the content has very informative ideas, waiting for the next update...
SAS Training in Chennai
SAS Training Center in Chennai
SAS Analytics Training in Chennai
SAS Training in Anna Nagar
SAS Training in Tnagar
clinical sas training in chennai
Mobile Testing Training in Chennai
QTP Training in Chennai
Hibernate Training in Chennai
DOT NET Training in Chennai

 
At 12:31 AM, Blogger High Technologies Solutions said...

I read Your Post & really it is very Nice and Informative Post... Thanks for Sharing & Keep Doing Otherwise If anyone Want to Learn Data analytics Training with Adv. Level So You Can click below

Certified SAS Training Center with Placements offer also

sas training institute in delhi
sas training institute in Noida

 
At 8:44 PM, Blogger Jayalakshmi said...

it was a wonderful chance to visit this kind of site and I am happy to know. thank you so much for giving us a chance to have this opportunity.. This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points.


Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery





 
At 2:17 AM, Blogger ram said...

great article and great content oracle training in chennai

 
At 10:20 PM, Blogger shiva said...

Finding the time and actual effort to create a superb article like this is great thing. I’ll learn many new stuff right here! Good luck for the next post.
Cyber Security Training Course in Chennai | Certification | Cyber Security Online Training Course | Ethical Hacking Training Course in Chennai | Certification | Ethical Hacking Online Training Course | CCNA Training Course in Chennai | Certification | CCNA Online Training Course | RPA Robotic Process Automation Training Course in Chennai | Certification | RPA Training Course Chennai | SEO Training in Chennai | Certification | SEO Online Training Course

 

Post a Comment

<< Home