全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3239 7
2012-06-24
悬赏 1 个论坛币 未解决
如果限制某数据集的行数,如果记录数不足n(如6)条时,补充空行,该如何编写程序,如:
data a;
set a;
if.... then ...
run;
二维码

扫码加我 拉你入群

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

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

全部回复
2012-6-24 23:06:49
example:
data a;
x=1;output;
x=2;output;
x=3;output;
x=4;output;
run;

data b (drop=i j);
do i=1 to  nobs;
  set a end=last nobs=nobs;
  output;
end;
  if last and (i-1)<6 then do;
    do j=1 to (6-i+1);
     x=. ;output;
        end;
        end;
run;
二维码

扫码加我 拉你入群

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

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

2012-6-24 23:22:39
webgu 发表于 2012-6-24 23:06
example:
data a;
x=1;output;
如果变量不止一个呢?
二维码

扫码加我 拉你入群

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

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

2012-6-24 23:48:42
燕婉 发表于 2012-6-24 23:22
如果变量不止一个呢?
复制代码
二维码

扫码加我 拉你入群

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

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

2012-6-26 07:38:26
tj0412ymy 发表于 2012-6-24 23:48
Moving the  call missing(of _all_) into the loop makes it logically better and save (19) times unwanted execution of  "call missing(of _all_)".

data test(drop=i);
    set sashelp.class end=eof ;
    output;
   
    if eof then do;
      do i=1 to 6;
          call missing(of _all_);
      output;
    end;
    run;

    proc print noobs;run;
二维码

扫码加我 拉你入群

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

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

2012-6-26 09:40:08
bobguy 发表于 2012-6-26 07:38
Moving the  call missing(of _all_) into the loop makes it logically better and save (19) times unw ...
Everyone knows this logic. Did you test your code? Did it really works except missing an end? hehe~
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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