1

输入:

G0894 x 1 x 3 x 1 k 1
C4458 x 1 k 5
C9057 x 7 x 4 x 4 x 3 x 5

期望的输出:

G0894 x 1
G0894 x 3
G0894 x 1
G0894 k 1
C4458 x 1
C4458 k 5
C9057 x 7
C9057 x 4
C9057 x 4
C9057 x 3
C9057 x 5

这就是我想出的:

data want;
    infile cards missover;
    input id $ @;
    do while (1);   
        input letter $ number @;
        if letter EQ ' ' then leave;
    output;
end;
cards;
G0894 x 1 x 3 x 1 k 1
C4458 x 1 k 5
C9057 x 7 x 4 x 4 x 3 x 5
;
run;

确实有效,但由于我们一直在讨论课堂上的双尾 @@,我想我应该使用它。这是我的另一种方法:

data want;
    infile cards missover;
    input id $ @;
    input letter $ number @@;
cards;
G0894 x 1 x 3 x 1 k 1
C4458 x 1 k 5
C9057 x 7 x 4 x 4 x 3 x 5
;
run;

它会产生一个错误,说明使用missover@@不一致的方式。我究竟做错了什么?

4

2 回答 2

2

There is no way in your program for the data step to ever advance to the second row of input data. That is what the error message is telling you.

The @@ tells SAS that it should keep the line pointer and column pointer the same when it starts the next data step iteration. The MISSOVER option tells SAS not to go to a new line when it cannot find data to meet the current input request. Hence there is no way for the line pointer to ever advance to line two.

于 2016-04-02T19:40:56.037 回答
0

双尾随符号 (@@) 在 DATA 步的多次迭代中保存一条记录,直到到达记录的末尾。但是,当控制返回到 DATA 步的顶部时,单个尾随 at 符号 (@) 会释放一条记录。

尝试这个:

data want;
    infile cards missover;
    input id $ letter $ number @;
    do while (letter ne '' or number ne .);
        output;
        input letter $ number @;
    end;
cards;
G0894 x 1 x 3 x 1 k 1
C4458 x 1 k 5
C9057 x 7 x 4 x 4 x 3 x 5
;
run;
于 2016-06-14T10:06:03.360 回答