PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 10, 2022

[FIXED] How can I get SAS to forget decimal places i variables?

 August 10, 2022     decimal, formatting, sas     No comments   

Issue

I have a problem with decimal places in my SAS-variables.

I have two numeric variables which I want to compare in SAS. They are both formatted with numx10.1 and one of the variables is calculated like this:

avg(delay)/30.44 as delay_months  format=numx10.1

I want to compare the two values in a datastep using

where var1^=delay_months ;

But even thought both variables have the same value for example. 4,1, SAS still shows this observation in the datastep with the where-statement. I guess it is because of the decimals in the delay_months variable.

How can I get SAS to forget the decimal places and only focus on the number I see - for example 4,1?


Solution

Format does not change the value - it is only the way SAS represents it to you. One suggestion could be rounding during comparison (or when you create the variables)

where round(var1, 0.1) ^= round(delay_months, 0.1);

SAS uses floating-point representation for numeric values. Because of that sometimes what you see is not what it is. More about that in SAS documentation



Answered By - Grinvydas Kareiva
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing