楼主: dxystata
459 3

[问答] 如何在标红的观测后面加空行 [推广有奖]

版主

大师

34%

还不是VIP/贵宾

-

TA的文库  其他...

Software

中英文Ebook

R学习

威望
2
论坛币
182303 个
通用积分
15205.6031
学术水平
208 点
热心指数
271 点
信用等级
174 点
经验
291233 点
帖子
5377
精华
1
在线时间
13479 小时
注册时间
2006-6-21
最后登录
2024-4-27

初级学术勋章 初级热心勋章 中级热心勋章 初级信用勋章

20论坛币
  1. data aaa;
  2. input x;
  3. cards;
  4. .
  5. .
  6. .
  7. 1
  8. 1
  9. 2
  10. 2
  11. 2
  12. .
  13. .
  14. 3
  15. 3
  16. ;
  17. run;
复制代码
如何在标红的观测后面加空行,谢谢!

最佳答案

乐天天12300 查看完整内容

/*空行是字符型缺失,所以你的x值要转为字符型*/ data bbb; set aaa nobs=last; x_new=strip(x); if (x_new^=lag(x_new) and _n_ ^=1) then do; temp=x_new; call missing(x_new); output; x_new=temp; end; output; if _n_=last then do; call missing(x_new); output; end; ...
关键词:cards Input Data card RDS
/*空行是字符型缺失,所以你的x值要转为字符型*/
data bbb;
    set aaa nobs=last;
    x_new=strip(x);
    if (x_new^=lag(x_new) and _n_ ^=1) then
        do;
            temp=x_new;
            call missing(x_new);
            output;
            x_new=temp;
        end;
    output;
    if _n_=last then
        do;
            call missing(x_new);
            output;
        end;
    rename x_new=x;
    drop temp x;
run;

使用道具

藤椅
whymath 发表于 2022-4-3 22:28:32 |只看作者 |坛友微信交流群
哪些观测是标红的?

使用道具

板凳
dxystata 发表于 2022-4-4 15:49:02 |只看作者 |坛友微信交流群
whymath 发表于 2022-4-3 22:28
哪些观测是标红的?
.
.
.
1
1
2
2
2
.
.
3
3

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-27 23:41