看到这里就有点愣住了。
我有一个具有不同长度值的 SAS 变量。
如果变量所需的内存低于阈值(48 字节),我会向变量附加空格,以便它达到该内存分配。
我该如何在 SAS 中执行此操作?
更重要的是,在哪里可以找到有关 SAS 中单个空格(或任何其他字符/类型)占用的内存的文档?
编辑:
stevepastelan 的回答实际上很完美:)
Slightly stunned here.
I have a SAS variable that has values of varying lengths.
If the memory required for the variable is below a threshold(48bytes), I have the append white spaces to the variable so that it reaches that memory allocation.
How would I do this in SAS?
More importantly, where can I find documentation regarding the memory taken up by a single white space(or any other character/type) in SAS?
Edit:
stevepastelan's answer was perfect actually :)
发布评论
评论(2)
SAS 中的字符变量会自动填充到右侧以填充其长度,但是某些语句(例如 PUT 语句)可能会在显示时修剪它们。
您可以使用格式强制输出,例如:
将以下内容写入 SAS 日志:
Character variables in SAS are automatically padded to the right to fill their length, however, certain statements, such as the PUT statement, may trim them when displaying.
You can use formats to force the output, ex:
Writes the following to the SAS log:
我想不出在什么情况下你会想要这样做。您能否详细说明一下原因,以启发我们。同时,这应该为您提供所需的内容:
http://support .sas.com/resources/papers/proceedings09/010-2009.pdf
除非我读错了,否则 Itzy 是对的。它们是固定长度变量,因此 20 个字节的长度存储在内存中时将占用 20 个字节。
如果需要填充值,可以使用重复功能:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245939.htm
I cant think of any circumstances in which you would want to do that. Can you elaborate on the why to enlighten us. In the meantime this should provide you with what you require:
http://support.sas.com/resources/papers/proceedings09/010-2009.pdf
Unless I've misread it then Itzy is right. They are fixed length variables so a length of 20 bytes will take up 20 bytes when stored in memory.
If you need to pad a value you can use the repeat function:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245939.htm