全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1285 2
2014-03-26
这是代码:
data test_1;
input (nmarital nkids nsex)(1.)@@;
if nkids>0 and nmarital=1 then marital='single_with_kids';
if nkids>0 and nmarital=2 then marital='married_with_kids';
if nkids=0 and nmarital=1 then marital='single';
if nkids=0 and nmarital=2 then marital='married';
if n(nmarital--nsex) eq 0 then do;
input;
return;
end;
cards;
102
211
232
202
222
221
202
212
201
122
201
202
122
;
proc print;
run;
请问:if n(nmarital--nsex) eq 0 then do; input; return; end;代表什么呢?书里说是“检查观测行的结束”。这里的n是什么意思?eq 0又是什么意思呢?这段语句有什么特殊意义呢?请大虾回答下,谢谢!

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-3-26 19:18:02
n()函数是检查个数用的,一般x1-x10是指x1,x2,x3...,x10;而如果一系列变量之间不是这种简单的关系的话,就可以用--来表示,比如说input a b c; a--c就是指a,b,c;eq就是equal(等于)的缩写;
这一句的意思是如果有一行的这三个变量的数目都是0,那么输入就结束了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-3-26 21:34:47
intheangel 发表于 2014-3-26 19:18
n()函数是检查个数用的,一般x1-x10是指x1,x2,x3...,x10;而如果一系列变量之间不是这种简单的关系的话,就可 ...
太感谢了!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群