简体   繁体   English

如何让 SAS 忘记小数位 i 变量?

[英]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.

相关问题 我如何舍入到小数点后三位 - how do i round to 3 decimal places 如何将浮点数四舍五入到小数点后两位,合并当前月份和年份,并修复我的循环? - How can I round my float to two decimal places, incorporate the current month and year, and fix my loop? 如何打印小数点,直到没有两个重复的零? - How can I print decimal places, up-to the point there are not two repeating zeros? 使用 Razor 视图引擎 - 如何格式化小数值以包含逗号和两位小数? - Using Razor view engine - how do I format a decimal value to have commas and two decimal places? 如何在 Crystal Reports 2008 中将数字字符串值格式化为 2 个小数位? - How do I format numeric string value to 2 decimal places in Crystal Reports 2008? 如何将小数点分隔符设置为逗号? - How can I set the decimal separator to be a comma? 如何将变量设置为2位小数 - How to set the variable to 2 decimal places 我如何在C ++中优雅地格式化字符串,以便它被舍入到6个小数位并且有额外的'0'或'9'被修剪 - how do I elegantly format string in C++ so that it is rounded to 6 decimal places and has extra '0's or '9's trimmed 如何使用不同的十进制符号将数字格式化为货币 - How can I format a number to curreny with differend decimal signs 如何将十进制值格式化为小时和分钟? - How can i format a decimal value into hours and minutes?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM