在SAS中创建虚拟变量时,有关小数规范的错误
我是SAS的新手,想创建一个简单的虚拟变量(男性
),该变量等于1,如果sex = 1
,则等于0,如果sex = 2 <2
/代码>。但是,我收到错误消息:
错误:2的小数规范必须小于1。
我如何解决此问题的宽度规范?这是我使用的代码:
DATA WORK.BMI_D ;
SET WORK.BMI ;
IF SEX = 1 THEN MALE = 1;
ELSE MALE = 0;
RUN;
变量性爱
具有长度8
,type 数字
和格式f8.2
。我在做什么错?
I am very new to SAS and want to create a simple dummy variable (MALE
) that equals 1 if SEX = 1
, and equals 0 if SEX = 2
. However, I get error messages: ERROR: The decimal specification of 2 must be less than the width specification of 1.
How do I solve this? This is the code I use:
DATA WORK.BMI_D ;
SET WORK.BMI ;
IF SEX = 1 THEN MALE = 1;
ELSE MALE = 0;
RUN;
The variable SEX
has length 8
, type Numeric
and format F8.2
. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尚未显示出生成该错误消息的代码,但为什么不只是删除您已附加到可变性别的不合逻辑格式。也许该错误是从稍后的步骤中尝试显示性别的宽度仅为1个字节,并且在显示字符串之类的字符串之类格式将产生。
由于不需要使用特殊的显示格式来为1和2的数字值2,只需从性别中删除格式,然后看看是否解决了问题。
You have not showed the code that is generating that error message but why not just remove the illogical format that you have attached to the variable SEX. Perhaps the error is from later step that is trying to display SEX with a width of only 1 byte and is having trouble display the strings like
1.00
or2.00
that the F8.2 format would generate.Since there is no need to use a special display format for numeric values of 1 and 2 just remove the format from SEX and see if that solves the issue.