## Subtracting numbers

Solved
Regular Contributor
Posts: 243

# Subtracting numbers

Hi All,

I am subtracting count2 from count1. I have some missing variables (which is actually zero) and in the result column it shows (.) instead of a munber i am expecting. can someone please help.

Data want;
set have;
Result = (count2-count1);
run;

Count1    Count2    Result

.               5             .

2              6             4

.               3             .

Accepted Solutions
Solution
‎10-30-2015 12:16 PM
Super User
Posts: 9,888

## Re: Subtracting numbers

Try

``result = sum(count2,-count1);``
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

All Replies
Solution
‎10-30-2015 12:16 PM
Super User
Posts: 9,888

## Re: Subtracting numbers

Try

``result = sum(count2,-count1);``
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 23,265

## Re: Subtracting numbers

Do you want the missing number treated as 0?
To get around this you can use the sum function instead.

result = sum(count2, -1*count1);
🔒 This topic is solved and locked.