BookmarkSubscribeRSS Feed
HitmonTran
Pyrite | Level 9

Hi,

 

I am trying to create a proc report that page break by treatment group (variable trtgrp) and laboratory parameter (variable param).

 

HitmonTran_0-1641937936808.png

 

below is my code:

%macro dorpt (trtgrp=);
proc report data=final nowindows spacing=1 headskip headline split='|' spanrows; where trtgrp = "&trt" ; by param; column trtgrp param avisitn avisit atoxgrn lbtox (/*"^S={borderbottomcolor=black borderbottomwidth=1} Baseline Result"*/'Baseline Result' col1-col5); define trtgrp / order noprint; define param / order noprint; define avisitn / order noprint; define avisit / group " " style(column)={asis=on width=2.8in just=left} style(header)={just=center}; define atoxgrn / order noprint; define lbtox / order " " style(column)={width=1.4in just=left} style(header)={just=left}; define col1 / display "Normal" style(column)={width=.9in just=center} style(header)={just=center}; define col2 / display "Grade 1" style(column)={width=1.2in just=center} style(header)={just=center}; define col3 / display "Grade 2" style(column)={width=1.2in just=center} style(header)={just=center}; define col4 / display "Grade 3" style(column)={width=1.2in just=center} style(header)={just=center}; define col5 / display "Grade 4" style(column)={width=1.2in just=center} style(header)={just=center}; * break after param / page; compute after avisitn; line @1 " "; endcomp; /* compute before param; line @1 " "; line @2 param $200.; endcomp;*/ run;

%mend;

%dorpt(trt=%str(1.0 mg/Placebo));
%dorpt(trt=%str(2.0 mg/Placebo));
4 REPLIES 4
ballardw
Super User

First thing, your shown code should throw an error because the parameter defined in the macro is TRTGRP= but us calls with TRT=.

 

Did you try: BY Param Trtgrp;  ? If the data isn't sorted to use that add the NOTSORTED to the by statement if your data is grouped in the data set as wanted. If not sort/group it before proc report.

You  could use the #BYvar and #ByVal approach in title statements to get the sort of heading you show.

Param would be #Byvar1 with #Byval1 and Trtgrp would be #byvar2 and #byval2 in the order I show.

 

Likely you wouldn't want those variables in the Columns but I may be wrong.

HitmonTran
Pyrite | Level 9

thank you, the #BYVAR worked but now it's showing titles I don't need.  I tried using title10="  "; but it still shows.  How would I get rid of the red circle?

 

 

HitmonTran_0-1642018992587.png

  title8 j=l "Laboratory Parameter: #byval2";
  title9 height=9pt j=l "Treatment Group: &trt";

    proc report data=final nowindows spacing=1 headskip headline split='|' spanrows;
      by trtgrp param;
column avisitn avisit atoxgrn lbtox (/*"^S={borderbottomcolor=black borderbottomwidth=1} Baseline Result"*/'Baseline Result' col1-col5); define avisitn / order noprint; define avisit / group " " style(column)={asis=on width=2.8in just=left} style(header)={just=center}; define atoxgrn / order noprint; define lbtox / order " " style(column)={width=1.4in just=left} style(header)={just=left}; define col1 / display "Normal" style(column)={width=.9in just=center} style(header)={just=center}; define col2 / display "Grade 1" style(column)={width=1.2in just=center} style(header)={just=center}; define col3 / display "Grade 2" style(column)={width=1.2in just=center} style(header)={just=center}; define col4 / display "Grade 3" style(column)={width=1.2in just=center} style(header)={just=center}; define col5 / display "Grade 4" style(column)={width=1.2in just=center} style(header)={just=center}; compute after avisitn; line @1 " "; endcomp; run;
AD16
Calcite | Level 5

Just use options nobyline;

Ksharp
Super User

I think you can code like this :

 

%macro dorpt (trtgrp= , param= );
title "XXXXXX  &trtgrp ";
title2 "YYYYYYYY &param ";
proc report data=final nowindows spacing=1 headskip headline split='|' spanrows;
      where trtgrp = "&trtgrp"  and param= "&param" ;
 column ...........

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3106 views
  • 0 likes
  • 4 in conversation