BookmarkSubscribeRSS Feed
GN0001
Barite | Level 11

Hello team,

 

Divide two numbers in SAS, which their data type is number and I get .

 

How to fix this issue?

 

Regards,

Blue

Blue Blue
11 REPLIES 11
jimbarbour
Meteorite | Level 14
The dot means "missing." One or both of the variables is not a valid number or the operation is not valid (I think division by zero would result in a missing value if SAS doesn't issue an error).

Can you write the values of the two numbers into the log?

Jim
jimbarbour
Meteorite | Level 14

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:

jimbarbour_0-1623971638383.png

 

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

ballardw
Super User

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).

 

himself
Pyrite | Level 9
Hi,
Kindly share hos your data looks like.
Thanks
GN0001
Barite | Level 11
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
Blue Blue
PaigeMiller
Diamond | Level 26

@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).

--
Paige Miller
Tom
Super User Tom
Super User

@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.)

andreas_lds
Jade | Level 19

Please read the log, it should explain why you see the . in the results.

PaigeMiller
Diamond | Level 26

@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?

--
Paige Miller
GN0001
Barite | Level 11

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

 

 

Blue Blue

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 2231 views
  • 8 likes
  • 8 in conversation