SAS:无法在数据集中添加变量
我有一个数据集,并且正在尝试使用现有的数据集添加四个新变量。我一直遇到一个错误,说代码不完整。我很难看到它不完整的地方。我该如何解决?
data dataset;
input ID $
Height
Weight
SBP
DBP
WtKg = Weight/2.2;
HtCm = Height/2.4;
AveBP = DBP + (SBP - DBP)/3;
HtPolynomial = (2*Height)**2 + (1.5*Height)**3;
datalines;
001 68 150 110 70
002 73 240 150 90
003 62 101 120 80
run;
I have a data set and am trying to add four new variables using the existing ones. I keep getting an error that says the code is incomplete. I'm having trouble seeing where it is incomplete. How do I fix this?
data dataset;
input ID $
Height
Weight
SBP
DBP
WtKg = Weight/2.2;
HtCm = Height/2.4;
AveBP = DBP + (SBP - DBP)/3;
HtPolynomial = (2*Height)**2 + (1.5*Height)**3;
datalines;
001 68 150 110 70
002 73 240 150 90
003 62 101 120 80
run;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(2)
您没有用半隆结束
输入
语句。输入
从外部数据读取变量(在这种情况下,使用Datalines
语句的在线数据)。在您指定的方式中,并未在输入
中创建新变量。使用
输入
在数据的五个变量中读取。之后,根据这五个读取变量创建新变量:You did not end your
input
statement with a semicolon.input
reads variables from external data (in this case, in-line data with thedatalines
statement). New variables are not created withininput
in the way you've specified.Use
input
to read in the five variables of your data. After that, create new variables based on those five read-in variables:纠正2个错误应解决以下问题:
从数据读物中读取最后一个字段后,添加一个半隆(即DBP。
)
(此问题的先前版本使用了指数的 ^符号。)而不是 ^提高某物的力量,而是使用**
为参考,描述了SAS算术运算符
在上面进行2个校正后,我在下面进行了修订的代码,没有任何错误。
Correcting 2 errors should fix this:
Add a semicolon after the last field being read in from the datalines, which is DBP.
(A previous version of this question used the ^ symbol for exponents.) Instead of ^ to raise to the power of something, use **
For reference, SAS arithmetic operators are described here.
After making the 2 corrections above I ran the revised code below without any errors.