BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
carslan
Calcite | Level 5

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,

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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

8 REPLIES 8
Cynthia_sas
SAS Super FREQ

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

BrunoMueller
SAS Super FREQ

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;
Cynthia_sas
SAS Super FREQ

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

carslan
Calcite | Level 5

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!

Cynthia_sas
SAS Super FREQ

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;

Ksharp
Super User

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

Cynthia_sas
SAS Super FREQ

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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