我们怎样才能将大观察以相同的顺序放在同一个空格和单词中

时间:2016-09-05 05:36:09

标签: sas

有人可以帮帮我吗?

我有以下数据集:

    data have;
    id    name country 
    100   abc   ind    

只是为了清楚地理解,第4栏是评论,我在下面添加

comments:
"SWIFTT LIST BRUPI
ACTION REQUIRED: REASSESS ASUP TO PICKUP INCM
Refer to note dated 21/07/2016 entered by TDEMP003.
ACTION TAKEN:  I have reassessed Asupp based on the income from 25/07/2016. Asupp rate is now $69.00 ($34.50 each).
Outcome of call to client No
Letter sent: Yes

Client Number                                                                       357-208-501 
Entitlement Date                                                                25/07/2016  

Gross SA                                                             $-   
Gross Wages                                                          $823.31 
Extra Income from Assets                                         $-   
TOTAL GROSS INCOME                                               $823.31 

所以有4列。

我希望结果像这样;

        id 100
      name abc
   country ind
  comments "SWIFTT LIST BRUPI
            ACTION REQUIRED: REASSESS ASUP TO PICKUP INCM
            Refer to note dated 21/07/2016 entered by TDEMP003.
            ACTION TAKEN:  I have reassessed Asupp based on the income  
            25/07/2016. Asupp rate is now $69.00 ($34.50 each).
            Outcome of call to client No
            Letter sent: Yes

            Client number 12345

            Entitlement 
            Date 25/07/2016                                                     

            Gross SA                                                             
            Gross Wages                                                             $823.31 
             Extra Income from Assets                                            $-   
           TOTAL GROSS INCOME                                            $823.31 

我尝试使用以下代码:

data _null_;
set client_details;

file " &WORK_DIR_PATH/&filename..doc" noprint lrecl=1200 print;
       put 'ID' @ 30 id /;
       put 'Client name' @30 Name /;
       put 'country' @30 country /;
       put 'comments' @30 comments ;
;
run;

我在这里寻找“评论”字段(第4栏)。我不能按顺序安排他们在现场显示的顺序。我的reuslts看起来很难看。我的意思是单词和数字的显示顺序与表中的顺序不同。所以任何人都可以告诉我们如何将这个重要的观察结果写成多行,或者说它是如何显示行的。

1 个答案:

答案 0 :(得分:0)

这样做的一种方法是通过lrecl定义最大行长度,并在flowover语句中设置file选项,例如:

/*Create file with long line that we want to split across 2 lines*/
data _null_;
    file "%sysfunc(pathname(work))/test.text" lrecl = 10 flowover;
    put '01234567890123456789';
run;

/*Check that we get 2 lines*/
data _null_;
    infile "%sysfunc(pathname(work))/test.text";
    input;
    put _INFILE_;
run;

N.B。设置lrecl将限制输出文件中所有行的长度,而不仅仅是打印真正长变量的行。如果这不是您想要的,那么另一种选择就是将其切割成子串并一次打印出来。