更新时间:2023-02-21 16:27:13
new =的原因。
在您的示例中是因为SAS无法将逗号识别为十进制分隔符。请参阅日志中的注释。
The reason new = .
in your example is because SAS does not recognize the comma as a decimal separator. See the note in the log.
注意:函数INPUT的无效参数在第4行第11列。
old = 1, 61个新=。 错误 = 1 N = 1
注意:在以下位置无法执行数学运算。操作的结果已设置为
个缺失值。
NOTE: Invalid argument to function INPUT at line 4 column 11. old=1,61 new=. ERROR=1 N=1 NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to missing values.
文档包含各种SAS格式的列表。根据文档,您似乎可以使用 COMMAX
信息。
The documentation contains a list of various SAS informats. Based on the documentation it looks like you can use the COMMAX
informat.
COMMAXw.d-写入数值,其句点每三位分隔一个逗号,逗号分隔十进制小数。
COMMAXw.d - Writes numeric values with a period that separates every three digits and a comma that separates the decimal fraction.
修改后的代码如下:
data temp;
old = '1,61';
new = input(old,commax5.);
run;
proc print;
结果为:
Obs old new
1 1,61 1.61
如果您希望将 new
变量保留为相同格式,则只需添加语句 format new commax5。;
转到数据步骤。
If you want to keep the new
variable in the same format you can just add the statement format new commax5.;
to the data step.
感谢汤姆指出SAS在 INPUT()
中使用了信息格式功能。
Thanks to Tom for pointing out that SAS uses informats in the INPUT()
function.