全部版块 我的主页
论坛 提问 悬赏 求职 新闻 读书 功能一区 学习笔记1.0
1289 0
2013-09-21

今天才开始看the little sas book!看到下面这个程序。

在SAS中运行如下程序,查看结果。

data test;

infile cards ;

input x @;

input y;

input z @@;

cards;

1 2 3 4 5 6

7 8 9 10 11 12

13 14 15 16 17  

;

run;

proc print;

run;

结果:

Obs

x

y

z


1

1

2

7


2

8

9

13

我自己的体验解释:


一个data步读取数据是多个循环构成的,读取一条观测记录就是循环一次。

一个input语句执行完之后立即换行继续下面的语句;

若在input语句之后加@,则该行以及之后的数据保留到下一个input语句开始读入数据;

若在input语句之后加@@,则该行以及之后的数据保留到下一次data步循环。

可以对比:

data test;

infile cards ;

input x @;

input y;

input z @;

cards;

1 2 3 4 5 6

7 8 9 10 11 12

13 14 15 16 17  

;

run;

proc print;

run;

结果:

Obs

x

y

z


1

1

2

7



以及:


data test;

infile cards ;

input x @;

input y;

input z ;

cards;

1 2 3 4 5 6

7 8 9 10 11 12

13 14 15 16 17  

;

run;

proc print;

run;

结果:

Obs

x

y

z


1

1

2

7


还可以添加 pull _all_ 查看变量的取值过程:

data test;

infile cards ;

put _all_;

input x @;

put _all_;

input y;

put _all_;

input z @;

put _all_;

cards;

1 2 3 4 5 6

7 8 9 10 11 12

13 14 15 16 17   

;

run;

proc print;

run;


二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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