The SAS Output Delivery System and reporting techniques

Proc Report with LINE

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Proc Report with LINE

Hallo All,

I have the dataset :

dataset.PNG

But I want to use PROC REPORT  and The LINE statement. 
I want to have before the KW  the values of KW , Test1 and Test2 in the report.

report.PNG

Can anyone know how to get this Report? Any help would be greatly appreciated.

Many Thanks,


Accepted Solutions
Solution
‎06-01-2015 04:08 PM
SAS Super FREQ
Posts: 8,820

Re: Proc Report with LINE

Hi:

  If the OP is using Test1 and Test2 in the extra line before each group, I am wondering whether NOPRINT would be more the type of look wanted on the report.

cynthia

cw.png

View solution in original post


All Replies
SAS Super FREQ
Posts: 8,820

Re: Proc Report with LINE

Hi:

  What code have you tried? Have you looked at using a COMPUTE/ENDCOMP block with a LINE statement. A COMPUTE BEFORE should get you most of what you need. I am confused a bit by your picture of what you want -- the results for Test1 and Test2 appear on every row on the report and they are the same on every row in your example. Are they ALWAYS the same on every report row???

cynthia

Super User
Super User
Posts: 7,725

Re: Proc Report with LINE

I agree, its not clear.  Why not have the additional bit as a by line and not have it in the report body.

SAS Super FREQ
Posts: 706

Re: Proc Report with LINE

hi

I agree with Cynthia about what results to display.

To get you started with COMPUTE blocks, here is a sample program that gets you close to what you want. There is no coloring, this can be achieved using Inline Formatting

data have;
  array _test1{3} _temporary_ (12, 15, 120);
  array _test2{3} _temporary_ (100, 225, 200);
  _test4 = "DEF";
  _i =
0;

 
do kw = "15W01", "15W02", "15W03";
    _i +
1;
    test1 = _test1{_i};
    test2 = _test2{_i};
   
   
do _ic = "AD", "BE", "CF";
      test3 = char(_ic,
1);
      test4 = char(_ic, 2);
      test5+1;
     
output;
   
end;
 
end;

 
drop _:;
run;

proc report data=have;
  column
    kw kw_c test1 test2 test3 test4 test5
;
  define kw / order noprint;
 
define kw_c / computed;
 
define test1 / analysis min;
 
define test2 / analysis min;

 
compute before kw;
    temp_kw = kw;
   
length printLine $ 256;
    printLine =
      catx(
":", "calendar-week", kw)
      !!
" " !! catx(":", "test1", test1.min)
      !!
" " !! catx(":", "test2", test2.min)
    ;
    line printLine $256.;
 
endcomp;

 
compute kw_C / char;
    kw_c = temp_kw;
 
endcomp;

run;
Solution
‎06-01-2015 04:08 PM
SAS Super FREQ
Posts: 8,820

Re: Proc Report with LINE

Hi:

  If the OP is using Test1 and Test2 in the extra line before each group, I am wondering whether NOPRINT would be more the type of look wanted on the report.

cynthia

cw.png

New Contributor
Posts: 4

Re: Proc Report with LINE

yes, I tried with COMPUTE/ENDCOMP block with a LINE statement but, I didn't find the result. But now I have it.

define KW / order order=data;

define Test1 /noprint analysis mean;
define Test2 /noprint analysis mean;


compute before KW;

        line @20 'calender-week ='
              @35 KW1 $5.
              @100 'Test1-Result ='
              @123 Test1.mean 5.
              @180 'Test2-Result ='
              @198 Test2.mean 5. ;      
endcomp;

I change the  DEFINE Test1 / display  with DEFINE Test1 / analysis mean. Now its ok.

Thank you all for your help!

SAS Super FREQ
Posts: 8,820

Re: Proc Report with LINE

Hi: the @20, @35 will only work in the LISTING destination, but will not work in ODS HTML or other ODS destination where you also want to use STYLES. So, you can't use that technique and still get the colors you want. Here's the code I used to take that screen shot. It is a variation of the code that Bruno used. The difference between my code and his code, is that I break at a different place, assuming that TEST1 and TEST2 are always the same for every value of KW.

  

Cynthia

     
  

ods html file='c:\temp\testreport.html';

proc report data=test nowd

  style(header)={background=yellow};

  column KW Test1 Test2 Test3 Test4 Test5;

  define KW / order style(column)={background=yellow};

  define Test1 / order noprint;

  define Test2 / order noprint;

  define test3 / display;

  define test4 /display;

  define test5 / display;

  compute before test2 / style={just=l background=orange font_weight=bold};

     line 'Calendar week: ' KW $5. ' Test 1: ' Test1 3.0 ' Test2: ' Test2 3.0;

  endcomp;

run;

ods html close;

Super User
Posts: 9,878

Re: Proc Report with LINE

Cynthia ,

I don't think so. The following worked in HTML and RTF destination .

proc report data=sashelp.class nowd;

column sex name weight;

define sex/order;

define name/display;

define weight/display;

compute after sex/style(lines)={asis=on};

line @4 'xxx'  @40 'yyy';

endcomp;

run;

Xia Keshan

SAS Super FREQ
Posts: 8,820

Re: Proc Report with LINE

Hi:

  I think it looks better in the RTF output than in the HTML. HTML might have a faint gray outline/box around what's written with the LINE command. So even though it sort of works, I don't count on it.

cynthia

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 818 views
  • 0 likes
  • 5 in conversation