行保持说明符@和@@用法详解:
多个input语句读取同一数据行的数据,使用单尾随符@
一个input语句在一个输入行中读取多个观测,则使用双尾随符@@
例1:
data b;
*input x y @;
input x y @@;
datalines;
3.16 2.9 5.8 3 4.9 4.17
;
proc print;
run;
例2:
data aa;
*input xxx @;
input xxx @@;
cards;
1 2 3
4 5 6
;
run;
proc print;
run;
例3: 经典的例子
data test;
*infile cards;
input x @; /*单个@,能Hold住,有效期到下一个input语句*/
input y; /*没有@,Hold不住,下一个input语句会去读新的一行*/
input z @@; /*两个@,Hold住没问题,保持当前行直到该行结束*/
cards;
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17
;
run;
proc print data=test;
run;
输出结果:
Obs x y z
1 1 2 7
2 8 9 13
<
多个input语句读取同一数据行的数据,使用单尾随符@
一个input语句在一个输入行中读取多个观测,则使用双尾随符@@
例1:
data b;
*input x y @;
input x y @@;
datalines;
3.16 2.9 5.8 3 4.9 4.17
;
proc print;
run;
例2:
data aa;
*input xxx @;
input xxx @@;
cards;
1 2 3
4 5 6
;
run;
proc print;
run;
例3: 经典的例子
data test;
*infile cards;
input x @; /*单个@,能Hold住,有效期到下一个input语句*/
input y; /*没有@,Hold不住,下一个input语句会去读新的一行*/
input z @@; /*两个@,Hold住没问题,保持当前行直到该行结束*/
cards;
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17
;
run;
proc print data=test;
run;
输出结果:
Obs x y z
1 1 2 7
2 8 9 13
<