0

I have a range of large (4- or 5-digit) numbers, which I need to raise to the -1 power. Because the numbers are all so large, they are obviously going to be very small when raised to that power. When I do it in SAS (using the elementwise operator), all the numbers in the output get rounded(?) to -1. So I get nothing but a lot of minus ones for the output.

Is this indeed the result of rounding? Can I get around this by formatting the output in a certain way? If so, what is the syntax for this? Again, sorry for asking about such simple things, I'm utterly new to SAS.

Code:

proc iml; 
  use sasdata.have; 
  read all var {Distance} into D; 
  print D; 
  Dmin = -1##D; 
  print Dmin;
quit;
Joe
  • 62,789
  • 6
  • 49
  • 67
Mhoram
  • 421
  • 2
  • 6
  • 13
  • 1
    When you say elementwise operator, do you mean you're in IML? Or are you just using the language of a matrix language. Provide example code/data please. – Joe Oct 22 '15 at 15:12
  • In particular, I'm a bit confused by your suggestion they be rounded to -1. They might be rounded to *zero*, depending on how you're displaying them, but I don't see them being rounded to -1. That implies you have a bigger problem, perhaps incorrect usage of the power operator. – Joe Oct 22 '15 at 15:14
  • That's the problem. I **don't** want them rounded to anything. I want them displayed as they are, i.e., all different, albeit raised to the -1 power. Yes, this is in IML. – Mhoram Oct 22 '15 at 16:33
  • It's SAS that, I suspect, does the rounding. The code is as follows: 'proc iml; use sasdata.have; read all var {Distance} into D; print D; Dmin = -1##D; print Dmin; ' now the numbers in Distance, and in D, are all different, but Dmin consists of nothing but -1. I wonder why, and how I can get the real answers in Dmin. – Mhoram Oct 22 '15 at 16:37
  • Also, why is there no (readily apparent) way of doing line breaks here? – Mhoram Oct 22 '15 at 16:51
  • Comments don't have line breaks because they're comments and meant for short pieces.. You need to add that information to your question via edit. – Joe Oct 22 '15 at 16:53
  • Just to be clear, [tag:sas-iml] is quite distinct from [tag:sas] and should be tagged as such when you're using it. – Joe Oct 22 '15 at 16:54

2 Answers2

1

Your problem is that you're raising -1 to the power of 5000 (or whatever), as opposed to the opposite.

proc iml; 
  use work.have; 
  read all var {Distance} into D; 
  print D; 
  Dmin = D##-1; 
  print Dmin;
quit;
Joe
  • 62,789
  • 6
  • 49
  • 67
0

Never mind, I think I know what's been causing this. The problem was the order of operations! When I changed -1##D to D##-1, the strange transmogrification of all my numbers to -1 stopped, and I finally got the answers of the type I expected. I'm sorry, I'm very stressed and pressed for time at this moment, hence this dumb mistake in my code.

Mhoram
  • 421
  • 2
  • 6
  • 13