[英]How can I get SAS to forget decimal places i variables?
I have a problem with decimal places in my SAS-variables.我的 SAS 变量中的小数位有问题。
I have two numeric variables which I want to compare in SAS.我有两个数值变量要在 SAS 中进行比较。 They are both formatted with numx10.1
and one of the variables is calculated like this:它们都使用numx10.1
格式化,其中一个变量的计算方式如下:
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
. 4,1,SAS 仍然用where-statement
在数据步中显示这个观察结果。 I guess it is because of the decimals in the delay_months
variable.我想这是因为delay_months
变量中的小数。
How can I get SAS to forget the decimal places and only focus on the number I see - for example 4,1?我怎样才能让 SAS 忘记小数位而只关注我看到的数字 - 例如 4,1?
Format does not change the value - it is only the way SAS represents it to you.格式不会改变值 - 它只是 SAS 向您表示它的方式。 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. SAS 对数值使用浮点表示。 Because of that sometimes what you see is not what it is.正因为如此,有时你看到的并不是它本来的样子。 More about that in SAS documentation 更多关于 SAS 文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.