SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Subtracting numbers

Accepted Solution Solved
Reply
Regular Contributor
Posts: 218
Accepted Solution

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: 7,808

Re: Subtracting numbers

Try

result = sum(count2,-count1);
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


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

Re: Subtracting numbers

Try

result = sum(count2,-count1);
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 19,815

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.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 320 views
  • 1 like
  • 3 in conversation