Hello team,
Divide two numbers in SAS, which their data type is number and I get .
How to fix this issue?
Regards,
Blue
Yes, division by zero results in a missing value. So either you're doing something invalid or you don't have valid numbers in one or both of the variables.
This code:
DATA ONE_ROW;
X = 1;
Y = 0;
Result = X / Y;
OUTPUT;
STOP;
RUN;
Yields a missing value as in the below:
Therefore you need to examine the variables and see what's really in them or make sure the divisor isn't zero.
Can you show your data, the record that is causing the problem? Can you post your code?
Jim
If you attempt to divide by 0 you should get a note in the log about attempted divide by 0.
Or if you have extremely small numbers that get treated functionally as 0.
Or if the range of values between the numerator and denominator where things just don't go well.
If this is the case you might consider the DIVIDE function.
data example;
input x y;
result1= divide(x,y);
datalines;
15 0
15 1E-350
1E300 1E-50
;
The function returns .I (capital i special missing) or .M ._ special missing depending one whether you would get "infinity" such as 1/0 or minus infinity or other cases. The results are missing but you have an indicator of what may have happened, especially in code with lots of calculations. This will also suppress notes to the log about divide by zero, missing values or "overflow" (values too big or small to store).
@GN0001 wrote:
Thanks for the responses.
My data is like this:
A_Rate B.Rate
0.36 0.74
Then they come as dot and then these two variables appear at the end of the dataset.
Regards,
Blue Blue
We've gone long enough in this thread and we still are not sure what you have done. You need to show us your code, and show us a representative portion of the data, including some data that illustrates the problem. Please provide the a portion of the data according to these instructions (as the above little fragment of text that I have quoted isn't the same as showing us your data set following the instructions and is not sufficient for anyone to diagnose anything).
@GN0001 wrote:
Thanks for the responses.
My data is like this:
A_Rate B.Rate
0.36 0.74
Then they come as dot and then these two variables appear at the end of the dataset.
Regards,
Blue Blue
You have not posted an CODE so we cannot tell why you might be getting missing values. (Or perhaps you have even created a character variable with a period in it instead of numeric variable with a missing value.)
Please read the log, it should explain why you see the . in the results.
@GN0001 wrote:
Divide two numbers in SAS, which their data type is number and I get .
How to fix this issue?
What is the "fix" that you think would be correct? What two values are being divided?
Hello all,
Thanks for all the response.
The reason I was getting dot is that I have renamed the variables in a proc sql, so for those we don't receive any thing if I use that variable in other place, the dot here is simply not the result of dividing by zero.
Respectfully,
Blue Blue
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.