sasproc-report

Customizing proc report


I need to produce a few reports and I always struggle with the report procedure to obtain the required result without messing too much with the initial dataset what takes a lot of time.

The dataset is of the following form:

ID  VAR1 VAR2 VAR3 
 1   1    2    3 
 1   4    5    6
 2   7    8    9
 2   10  11   12

and the output should be:

ID    VAR1
       VAR2
        VAR3

1     1
       2
        3

      4
       5
        6

2     7 
       8
        9

     10
      11
       12

Is there a good way (i.e. efficient) of producing the output using proc report? Becuase the only way I see is to manually create blank characters in ID variable and manually create the column with variables and using put function heavily to create spaces. The only thing proc report is used for is to create blank spaces between subjects by using sorting variables. The amount of time it takes is insane. I tried to find some good resources on that but with no success.

I will appreciate any suggestions. Thanks.


Solution

  • Sounds like you just want to use data step to produce your "report".

    Here is an outline:

    data _null_;
      set have;
      by id;
      array cols var1-var3;
      if first.id then put @1 id @;
      do index=1 to dim(cols);
        put @5+index cols[index] ;
      end;
      put;
    run;
    

    Results:

    1    1
          2
           3
    
         4
          5
           6
    
    2    7
          8
           9
    
         10
          11
           12
    

    Add a FILE statement to direct the output somewhere else. For example use FILE PRINT; to send the report to the listing output instead of the LOG.